You can start by creating a new pipeline where you add a Web Activity to the pipeline to make the initial API call :
- Set the URL to the API endpoint
- Use the GET method
- Configure Headers and Authentication as required by the API
- Store the response in a variable
APIResponse
Then you need to parse the initial API response :
- Add a Set Variable Activity to store the initial API response and det the variable
APIResponse
to@activity('WebActivity1').output
- Use a Parse JSON Activity to extract the
cursor
andtime_entries
from the response where you need to define the schema in the Parse JSON activity to match the structure of your API response.
Now you need to set up the pagination :
- Add an Until Activity to handle pagination.
- Set the condition to check if the
cursor
is null or empty (@empty(variables('cursor'))
). - Inside the Until Activity:
- Add a Web Activity to fetch the next page of data using the
cursor
.- Set the URL dynamically using the
cursor
value (@concat('https://api.example.com/time_entries?cursor=', variables('cursor'))
).
- Set the URL dynamically using the
- Use another Parse JSON Activity to extract the
cursor
andtime_entries
from the subsequent API response.
- Add a Web Activity to fetch the next page of data using the
- Set the condition to check if the
- Inside the Until Activity, add a Copy Data Activity to write the
time_entries
data to a file.- Configure the Source:
- Use the JSON response from the Web Activity as the source.
- Map the
time_entries
field to the source dataset.
- Configure the Sink:
- Set the destination (e.g., Blob Storage).
- Use dynamic content for the file name to ensure each page’s data is written to a separate file (
@concat('time_entries_', pipeline().RunId, '_', variables('cursor'), '.json')
).
- Configure the Source:
- In the Copy Data Activity, configure the sink file name dynamically.
- Use an expression like
@concat('time_entries_', pipeline().RunId, '_', variables('cursor'), '.json')
to generate unique file names for each page.ion!
- Use an expression like