Home > OS >  Azure Data Factory: Incrementing a number in the REST API request body
Azure Data Factory: Incrementing a number in the REST API request body

Time:01-26

In ADF, I am currently working on a copy data function from a REST API URL. In the POST request body there are parameters like this:

{
    "anyStateChange": true,
    "timeInterval": {
        "field": "requestedOn",
        "operator": "lastndays",
        "value": "1"
    },
    "paginationStartIndex": 1,
    "numberOfRecords": 20
}

API Returns 3 Fields like this :

{
    "totalResults": X
    "startIndex" : Y
    "itemsPerPage" : Z
}

I am trying to determine the best way to increment the paginationStartIndex until it runs out of records in the loop.

I tried doing some adjustments to pagination rules, and other options which want to increment the page in the URL which doesn't work here.

CodePudding user response:

For incrementing a number in a REST API request body, you can use a ForEach activity as below.

In the for each activity settings, pass the value as a range of numbers you want to pass as below:

Enter image description here

Then in the request body, pass the @{item()} for the parameter you want to increment sequentially.

Enter image description here

This will also act as pagination.

  • Related