REST Import pagination issue

flegare
Regular Contributor II
Regular Contributor II

I am trying to iterate through all the items received from target service with the following statement that works fine in Postman:

 

"pagination": {
    "nextUrl": {
        "nextUrlPath": "${response?.completeResponseMap?.itemsPerPage<10?null:'https://url/Users/?startindex='+Math.addExact(response.completeResponseMap.startIndex,response.completeResponseMap.itemsPerPage)}"
    }
}

 

It looks like computing the value is not happening as error coming back is: 

 

Failed url-${response?.completeResponseMap?.itemsPerPage<10?null:'https://url/Users/?startindex='+Math.addExact(response.completeResponseMap.startIndex,response.completeResponseMap.itemsPerPage)} with Error Message-null

 

Anyone has any idea as to what could the problem be?

Thanks in advance!

3 REPLIES 3

pmahalle
Valued Contributor II
Valued Contributor II

Hi @flegare ,

Can you share your whole import json where you are facing issue.


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

flegare
Regular Contributor II
Regular Contributor II

Hi @pmahalle ,

I looked further in the logs and observed the following exception:

"ecm-worker","2023-08-10T18:10:33.573+00:00","2023-08-10T18:10:33.222504381Z stdout F 2023-08-10 18:10:33,222 [quartzScheduler_Worker-2] DEBUG rest.RestProvisioningService  - Got Webservice API Response: [error:Error Illegal character in path at index 1: ${response?.completeResponseMap?.itemsPerPage<10?null:'https://url/Users/?startindex='+Math.addExact(response.completeResponseMap.startIndex,response.completeResponseMap.itemsPerPage)'}]"

In any case, here is the whole json:

{
	"accountParams": {
		"connection": "Concur",
		"processingType": "SequentialAndIterative",
		"statusAndThresholdConfig": {
			"accountThresholdValue": 100
		},
		"call": {
			"call1": {
				"callOrder": 0,
				"stageNumber": 0,
				"http": {
					"url": "https://url/Users/",
					"httpContentType": "application/json",
					"httpMethod": "GET",
					"httpHeaders": {
						"Authorization": "${access_token}",
						"Accept": "application/json"
					}
				},
				"listField": "Resources",
				"keyField": "accountID",
				"colsToPropsMap": {
					"accountID": "id~#~char",
					"name": "userName~#~char",
					"displayName": "userName~#~char",
					"status": "active~#~char",
					"customproperty1": "urn:ietf:params:scim:schemas:extension:enterprise:2~dot#0:User.employeeNumber~#~char",
					"customproperty2": "name.givenName~#~char",
					"customproperty3": "name.familyName~#~char",
					"customproperty4": "userName~#~char",
					"customproperty5": "preferredLanguage~#~char"
				},
				"pagination": {
				  "nextUrl": {
					"nextUrlPath": "${response?.completeResponseMap?.itemsPerPage<10?null:'https://url/Users/?startindex='+Math.addExact(response.completeResponseMap.startIndex,response.completeResponseMap.itemsPerPage)'}"
				  }
				},
				"statusConfig": {
					"active": "true",
					"inactive": "false"
				}
			},
			"call2": {
				"callOrder": 1,
				"stageNumber": 3,
				"http": {
					"url": "https://url/Users/${accountName}/",
					"httpContentType": "application/json",
					"httpMethod": "GET",
					"httpHeaders": {
						"Authorization": "${access_token}",
						"Accept": "application/json"
					}
				},
				"inputParams": {
					"dependentCall": true
				},
				"listField": "",
				"keyField": "accountID",
				"nextApiKeyField": "accountID",
				"colsToPropsMap": {
					"accountID": "id~#~char",
					"name": "id~#~char",
					"customproperty15": "urn:ietf:params:scim:schemas:extension:spend:2~dot#0:User.ledgerCode~#~char",
					"customproperty16": "urn:ietf:params:scim:schemas:extension:spend:2~dot#0:User.country~#~char",
					"customproperty17": "urn:ietf:params:scim:schemas:extension:spend:2~dot#0:User.reimbursementCurrency~#~char",
					"customproperty31": "STORE#ACC#ENT#MAPPINGINFO~#~char"
				},
				"acctEntMappings": {
				  "Role": {
					"importAsEntitlement": true,
					"listPath": "",
					"idPath": "urn:ietf:params:scim:schemas:extension:spend:2~dot#0:Role:roles",
					"keyField": "roleName"
				  }
				},
				"acctEntParams": {
					"processingType": "entToAcctMapping"
				}
			}
		}
	}
}

Thanks again!

 

flegare
Regular Contributor II
Regular Contributor II

Found a solution thanks to this post.

Solution: Initial URL set with '?startIndex=1&count=100' and pagination logic as :-
"pagination": {
"nextUrl": {
"nextUrlPath": "${response?.completeResponseMap?.itemsPerPage<100?null:'https://sample-url.com/Groups?count=100&startIndex='+Math.addExact(response.completeResponseMap.star...)}"
}
}