Data Stream - I cant access response body

Isaac Vicentini
Mega Sage
Mega Sage

Hi experts,

 

Context:

I created a Data Stream Action and am making an integration call with pagination.

The call is made successfully, then the Split is performed and I can successfully set the values ​​in the output variables.

 

Problem:
I created a Pagination Variable called beforeID, its initial value is empty and the next value is set by JSONPath Expression, but it doesn't work.

I tested the expression on an online website and was able to confirm that it is correct: https://jsonpath.com

 

data stream variable.png

 

API Response:

 

{
"latest_posts":[{"id":123},{"id":76407}]
}

 

 

Another problem I'm having, which may be linked to this first problem, is that I can't access the response_body from the pageResponse, it doesn't exist:

pageResponse.png

 

 

Thanks in advance!

 


Best regards,

Isaac Vicentini
MVP 2025


If my answer was helpful, mark it as Helpful or Accept as Solution.

2 REPLIES 2

Kaylin Lee
Tera Contributor

Just curious, have you tried using bracket notation in the JSONPath expression to access the id key?

$['latest_posts']['0'].['id']

 

I'm not sure if we can access response_body from the pageResponse variable. I know it even says this in the ServiceNow docs on Creating a Data Stream action that the pageResponse object in the pagination script contains the response_body. But I've tested it in a few different Data Stream actions with a few different APIs and I've never seen response_body within the pageResponse variable. I'd be curious if someone has but that's been my experience at least. I've also tried accessing the Response Body via the pagination variables but haven't had luck there either and am not sure this is possible. 
I'm curious though, is there a reason you need to access the response body in the pagination step? Versus just certain variables in the pageResponse or in the response body that can be accessed through the JSONPath Expressions? 

Beata I_owiecka
Kilo Guru

Hi @Isaac Vicentini,

 

If you want to parse the API response in a script - you should do it in the Parsing Script step - rather not in the Pagination Variables Script step - you can't see the API response results in Pagination step. Similarily, you can't access before_id as an input variable in the pagination step using the REST API response.

 

Use pagination step to decide whether you still want to get another page based on the input variables that you have and link the using data pills from the steps before the pagination (REST step is after the pagination step and you can't access the results yet).

 

You can parse the API response, in the Parsing Script step like this:

parsing-script.png

 

I hope that helps.

Have a great day! 🙂