Data Stream - I cant access response body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 08:05 AM - edited 04-22-2024 06:58 AM
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
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:
Thanks in advance!
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 11:49 AM - edited 05-24-2024 12:31 PM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 09:16 PM
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:
I hope that helps.
Have a great day! 🙂