Search code examples
paginationazure-logic-appsazure-api-managementresponse-headers

How to set up the link for the paginated files in the Get Rows(V2) Logic App connector and pass it via Azure API call?


I have created a Logic App and doing the pagination of the result retrieved by Get Rows(V2) connector. The threshold is set to 1500 and it is working fine. The test case file has 4484 records and the Until loop in the Logic App is iterating 3 times (1500, 1500 anf 1484), Now, i am trying to figure out how I can set up the link for these 3 paginated outputs so that they can be retrieved via the Azure API call.

Logic App flow enter image description here

I am calling this logic app through API but it giving the last result as the output. How can I set up the pages and links for them so that I can call the links and retreive all the records in 3 calls.

Thank you.


Solution

  • I am also not getting @odata.nextlink when I'm using the pagination. Only when the pagination setting is disabled -

    enter image description here

    - then I'm getting this at the end of the output:

    enter image description here

    I don't quite understand why you need this link though if you're already using the Skip count parameter, as I can see on your screenshot.

    Let's say you have 4,484 records in your table and you have the pagination setting set to 1,500. It doesn't mean that 1,500 records will be returned. The number of the returned records will depend on the default page size - e.g. you can get 2,048 records in the output.

    You can have a loop set up in your Logic App, so that the next time your Get rows (V2) action skips the first 2,048 records:

    enter image description here

    Having retrieved 2,048 + 2,048 = 4,096 records, next time you would use Skip Count = 4,096 and retrieve the last 388 records. When 0 records are left to retrieve, you exit the loop.

    At no point you'd have to use @odata.nextlink, but hopefully the logic described above will help you achieve the desired result.

    Comment:

    We are giving vendor access to this logic app via Azure API. Vendor calls the API, which triggers this logic app. Vendor uses the output JSON into the ADF at their end for further processing. When the JSON generated via logic app is more than 4MB, the vendor ADF pipeline fails. So, we need to implement pagination so that vendor can consume the JSON file in small batches. I am trying to get the @odata.nextlink in the JSOn output so that vendor can use that link to consume the full JSON output in multiple pages using the link. Hope now I am able to explain it in a better way. Thanks

    Updated answer:

    The bottomline is that switching on the pagination disables OData protocol links. You need to consider refactoring your solution so that instead of sending requests to the database directly the vendor should send requests to your Logic Apps, which will handle all the logic of communicating with the database and return the data to the vendor.

    When the vendor sends its first request to the Logic App, it can fetch etc. top 100 records (you can control the limit) and return them to the vendor. Then the vendor sends a new request to the Logic App indicating that it has already received 100 records. The Logic App fetches the next 100 records from the database, skipping the first 100, and returns them to the vendor. And so on, until all records have been fetched. The Logic App acts as a middleware, and you have full control over the process in its workflow.