Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

ServiceNow import job is not pulling/Updating all the users

SaiKiran
New Contributor
New Contributor

We are using Rest API connection to import the users from Servicenow. Sometimes job is failing to import the new users which are added in servicenow tabe and sometimes updates are not being reconciled for the exisiting users as well. 

please find the connection JSON we are using. Please suggest

{
    "authentications": {
        "userAuth": {
            "authType": "Basic",
            "url": "",
            "httpMethod": "GET",
            "httpHeaders": {},
            "properties": {
                "userName": "",
                "password": "”
            },
            "httpContentType": "application/json",
            "expiryError": "ExpiredAuthenticationToken",
            "retryFailureStatusCode": [403, 401, 500],
            "authError": [
                "InvalidAuthenticationToken",
                "AuthenticationFailed",
                "Authentication_ExpiredToken"
            ],
            "timeOutError": "Read timed out",
            "errorPath": "error.code",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",
            "tokenType": "Basic",
            "accessToken": ""
        }
           }
}
4 REPLIES 4

SumathiSomala
All-Star
All-Star

@SaiKiran Please share the logs and import json

Regards,
Sumathi Somala
If this reply answered your question, please Accept As Solution and give Kudos.

Hi Sumathi,

Thanks for the reply. Please find the below import JSON. 

{
"connection": "userAuth",
"url":
"httpMethod": "GET",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${access_token}"
},
"colsToPropsMap": {
"username": "u_number~#~char",
..................
},
"errorCode": "400",
"errorCodePath": "errorCode",
"userResponsePath": "result",
"pagination": {
"nextUrl": {
"nextUrlPath": "${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
}
}
}

try below json for import

{
  "accountParams": {
    "connection": "userAuth",
    "processingType": "SequentialAndIterative",
    "call": {
      "call1": {
        "callOrder": 0,
        "stageNumber": 0,
        "http": {
          "url": "https://<domain name>/api/now/table/sys_user?sysparm_limit=100",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/x-www-form-urlencoded",
          "httpMethod": "GET"
        },
        "statusConfig": {
          "active": "true",
          "inactive": "false"
        },
        "listField": "result",
        "keyField": "accountID",
        "colsToPropsMap": {
          "customproperty1": "employee_number~#~char",
          "CUSTOMPROPERTY2": "last_name~#~char",
          "customproperty3": "name~#~char",
          "CUSTOMPROPERTY4": "first_name~#~char",
          "CUSTOMPROPERTY5": "department~#~char",
          "CUSTOMPROPERTY6": "location~#~char",
          "CUSTOMPROPERTY7": "email~#~char",
          "CUSTOMPROPERTY8": "manager~#~char",
          "CUSTOMPROPERTY9": "country~#~char",
          "CUSTOMPROPERTY10": "phone~#~char",
          "CUSTOMPROPERTY11": "title~#~char",
          "name": "user_name~#~char",
          "status": "active~#~char",
          "accountID": "sys_id~#~char"
        },
        "pagination": {
          "nextUrl": {
            "nextUrlPath": "${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
          }
        }
      }
    }
  },
  "entitlementParams": {
    "processingType": "SequentialAndIterative",
    "entTypes": {
      "Group": {
        "entTypeOrder": 0,
        "entTypeLabels": {},
        "call": {
          "call1": {
            "connection": "userAuth",
            "callOrder": 0,
            "stageNumber": 0,
            "http": {
              "httpHeaders": {
                "Authorization": "${access_token}"
              },
              "url": "https://<domain name>/api/now/table/sys_user_group",
              "httpContentType": "application/json",
              "httpMethod": "GET"
            },
            "statusConfig": {
              "active": "true",
              "inactive": "false"
            },
            "listField": "result",
            "keyField": "entitlementID",
            "colsToPropsMap": {
              "entitlementID": "sys_id~#~char",
              "description": "description~#~char",
              "entitlement_value": "name~#~char",
              "displayname": "name~#~char",
              "status": "active~#~char",
              "updatedate": "sys_updated_on~#~char"
            }
          }
        },
        "entMappings": {
          "Group": {
            "listPath": "parent",
            "idPath": "value",
            "idColumn": "entitlementID",
            "mappingTypes": [
              "ENTMAP"
            ]
          }
        }
      },
      "Roles": {
        "entTypeOrder": 1,
        "entTypeLabels": {},
        "call": {
          "call1": {
            "connection": "userAuth",
            "callOrder": 0,
            "stageNumber": 0,
            "http": {
              "httpHeaders": {
                "Authorization": "${access_token}"
              },
              "url": "https://<domain name>/api/now/table/sys_user_role",
              "httpContentType": "application/json",
              "httpMethod": "GET"
            },
            "listField": "result",
            "keyField": "entitlementID",
            "colsToPropsMap": {
              "description": "description~#~char",
              "customproperty3": "elevated_privilege~#~char",
              "entitlementID": "sys_id~#~char",
              "entitlement_Value": "name~#~char",
              "displayname": "sys_name~#~char"
            }
          }
        }
      }
    }
  },
  "acctEntParams": {
    "entTypes": {
      "Group": {
        "call": {
          "call1": {
            "connection": "userAuth",
            "processingType": "http",
            "http": {
              "url": "https://<domain name>/api/now/v1/table/sys_user_grmember?sysparm_limit=10000",
              "httpContentType": "application/json",
              "httpMethod": "GET",
              "httpHeaders": {
                "Authorization": "${access_token}"
              }
            },
            "listField": "result",
            "acctKeyField": "accountID",
            "entKeyField": "entitlementID",
            "acctIdPath": "user.value",
            "entIdPath": "group.value",
            "pagination": {
              "nextUrl": {
                "nextUrlPath": "${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
              }
            }
          }
        }
      },
      "Roles": {
        "call": {
          "call1": {
            "connection": "userAuth",
            "processingType": "http",
            "http": {
              "url": "https://<domain name>/api/now/table/sys_user_has_role?sysparm_limit=10000",
              "httpContentType": "application/json",
              "httpMethod": "GET",
              "httpHeaders": {
                "Authorization": "${access_token}"
              }
            },
            "listField": "result",
            "acctKeyField": "accountID",
            "entKeyField": "entitlementID",
            "acctIdPath": "user.value",
            "entIdPath": "role.value",
            "pagination": {
              "nextUrl": {
                "nextUrlPath": "${headers?.Link?.split(';')?.size()==5?headers?.Link?.split(';')[2]?.replace('rel=\"prev\",<', '')?.replace('>','')?.trim():headers?.Link?.split(';')?.size()==4 && headers?.Link?.split(';')[2].contains('rel=\"next\",<')?headers?.Link?.split(';')[1]?.replace('rel=\"first\",<', '')?.replace('>','')?.trim():null}"
              }
            }
          }
        }
      }
    }
  }
}

Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

SumathiSomala
All-Star
All-Star

@SaiKiran Please try with below connectionJSON-Auth type basic

{
"authentications":{
"userAuth":{
"authType":"Basic",
"url":"https://XXXXXXXXXXXXX.service-now.com/",
"httpMethod":"POST",
"httpParams":{

},
"httpHeaders":{
"contentType":"application/x-www-form-urlencoded"
},
"httpContentType":"text/html",
"properties":{
"userName":"XXXXXXXXXXX",
"password":"XXXXXXXXXX"
},
"expiryError":"ExpiredAuthenticationToken",
"authError":[
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"timeOutError":"Read timed out",
"errorPath":"error.code",
"maxRefreshTryCount":5,
"tokenResponsePath":"access_token",
"tokenType":"Basic",
"accessToken":"Basic <Token>"
}
}
}

 

Also share the error logs

 

Regards,
Sumathi Somala
If this reply answered your question, please Accept As Solution and give Kudos.