Forum Discussion

rpc1235x's avatar
rpc1235x
New Contributor II
2 years ago

Coupa API Pagination with Dates in Service URL

Hey,

How can I adjust the following Service URL so that it extracts all available records? By default, Coupa API only allows 50 records, this is why I need to implement pagination. 

"https://XYZ.coupahost.com/api/invoices?offset=100&created-at[gt_or_eq]="+$date_1+"&created-at[lt_or_eq]="+$date_2

In the past, I have adjusted the pagination for service URLs without dates, but it's proving difficult to adjust with dates

What has worked in the past, in the REST GET:

Service URL: "https://XYZ.coupahost.com/api/invoices"

Has Next: eval(sl.ensureArray($.get('entity')).length > 0)

Next URL: "https://XYZ.coupahost.com/api/invoices?offset="+eval((snap.out.totalCount + 1) * 50)+"%26exported=false"

But when I try to add the dates, I keep getting 400 error code.

Thank you

  • Hi @andrew_wait

    I’m not that familiar with the Script snap, but believe its logger binds to the underlying Java platform logger. If SnapLogic is running on a Groundplex, meaning you manage it, then you will be able to access this log. However, I don’t believe this is easily accessible if we manage it (ie, is a Cloudplex) other that what you are already doing. I don’t think you’ll be able to see this in the designer.

    If snaplogic was running on a on-premise Groundplex, you could tail this log and see new script log entries as you validate.

    $ tail -f /opt/snaplogic/run/log/jcc.json
    
    {
        "ts": "2021-11-29T18:33:29.629Z",
        "lvl": "INFO",
        "fi": "<eval>:32",
        "msg": "Executing Transform Script.",
        "snlb": "Script",
        ...
    }
    
    • andrew_wait's avatar
      andrew_wait
      New Contributor

      Thanks for the response, even if it wasnt what I was hoping… instrumenting a script with log output for dev/debugging and having to run it and then go to the dashboard to get the logs from the status and then rinse and repeat is… clunky

      Suggestion: as it’s browser based write to the browser console so output is available in the browser dev tools console