|
Classic file types are no longer available for use as of January 2021. You can transition your classic files or download a PDF. Learn More

SAP BDC to Workiva API pagination issue

0

Comments

1 comment

  • Andrew McKenzie

    The way we solved this is with a command group that has this sequence of steps and runs so long as a dynamic variable called 'paginate' (whose value is defaulted to true earlier in the chain) remains true:

    1. The GET node - to call the API. Use a dynamic variable for the API URL (which can be set to the initial API endpoint value ahead of the command group).
    2. A JSON - Array to CSV node - to extract data from the response and transform it into a tabular format.
    3. A Workiva - Create File node - to store the transformed/tabular data as a file in a Wdata table (previously configured - you can do this in the chain or manually, depending on various factors).
    4. A Workiva - Import File into Table node - to actually import the file into the table.
    5. A Conditional node - this checks to see if there is an odata.nextLink response string in the response (from step #1). The easiest way to do this is paste a dummy version of the expected response in the 'Output Schema' section of the GET node, making sure it has the correct JSON structure (the values don't matter). Make sure it is a paginated response so that it includes the odata.nextLink key. Then, in the conditional node, you can add a check for a String, then for the value add the response (from step #1) and transform it via "Get Value from JSON" and select that odata.nextLink key. The condition we're using is "Is Not Blank" (although I think you could customise this depending on your needs).
    6. Based on the outcome of the conditional, either update the dynamic URL to be the URL value from the odata.nextLink key, in which case the loop will repeat and call that (next) URL in its next run---OR update the paginate value to be false, in which case the loop will exit. Then proceed with appropriate post-loop commands in your chain.

    I'm not sure that's optimal; that's just the way we built it. I think you could do a number of different things in steps 3/4 as well, such as perhaps just updating a single CSV file and only attaching it to a table once all calls are completed [EDIT: looks like Stack Files Across Command Group Iterations – Support Center might be the best resource for how to do this 'right'], but this was the way we did it. I'm interested to see if someone else has a better approach---I thought maybe there was even a template chain from Workiva for this use case, but I didn't see one.

    Here's a screenshot of that part of our chain for your reference. The 'Get File Properties' and the ultimate 'Write Sheet Data' chain are not essential but just included here since that's what our chain does.

    0

Please sign in to leave a comment.