Data Stream Pagination - empty sourceItem

medcherifzani
Tera Contributor

Hey Experts,

 

I'm trying to configure a pagination for a rest api in a data stream using flow designer.

As below the configuration of the data stream.

 

1. Pagination Setup Step :

medcherifzani_0-1704722580754.png

 

2. REST Step :

medcherifzani_1-1704723680918.png

 

3. Splitter Step :

medcherifzani_2-1704723744480.png


4. Script Parser step : (for tesing purpose, I'm passing the string 'sourceItem' to the 'item' property of the output)

medcherifzani_3-1704723810342.png

 

And finally the outputs of the data stream :

medcherifzani_4-1704723875528.png

 

I created a flow to test the data stream action :

medcherifzani_5-1704724234019.png

 

But when I test the flow, the log action message is empty :

medcherifzani_6-1704725500293.png

I checked the response body of the rest api and everything is working fine, I also double checked that the item path is good '$.results', any solution to solve this pagination issue ?

 

Best regards.

 

1 REPLY 1

Kaylin Lee
Tera Contributor

Hey there,

I think you may just need to parse your data in the script parser step. 
You could do something like:

var item = JSON.parse(inputs.sourceItem);
And then from there you'll just want to define the individual data points for your parsed data set in the script parser step.
For example:
glacier_parser.png
 
 
 
 
 
 
 
 
 
 
 
 
 
Any that you define in the Script Parser step will need to be defined as Outputs. Just like how you defined "Item" but just drilled down a little further. 
 
outputs.png
 
 
 
 
 
 
 
 
 
 
(Both screenshots are from the Data Stream Actions course on ServiceNow's developer site.)
 
In your splitter step your item path is set to $.results. You mentioned you verified this was correct but just to note in case - I haven't had too many experiences lately where my API response body is named "results" so if you continue to have issues make sure that is the correct path name and place to split your data via JSONPath notation.