How to obtain a response header value in a data stream action?

arielgritti
Mega Sage

Hi community,

 

I'm configuring a data stream action in Flow Designer. I'm stuck in the "pagination step".

How can I obtain a response header value?

 

The scenario is:

In the REST step, the answer from the external system has a "token" to know if is there more data to retrieve. The response header is called "x-foundation-continuation" (see an extract of the JSON answer)

 

arielgritti_0-1687620178682.png

 

The FD step execution runtime is showing it:

arielgritti_1-1687620388400.png

 

I need to use this value to change to true/false the getNextPage (read-only) variable in the pagination step, but I can't get it.

 

In this step (pagination) the two available variables are: variables and pageResponse. I'm trying using pageResponse but it seems empty.

arielgritti_0-1687621085525.png

 

The option to obtain it from the Response Body doesn't cover the need here, because the value is coming in the Response Header. 

I tried to do it like this; it doesn't works too.

 

arielgritti_0-1687621507666.png

 

 

Any help is welcome.

Thanks,

Ariel

 

 

5 REPLIES 5

arielgritti
Mega Sage

Following this article: https://hishowcase.service-now.com/kb?id=kb_article_view&sysparm_article=KB0756552

 

I found a potential solution/example of how to access the response_headers variable.

 

arielgritti_0-1687622489233.png

 

I'm testing it. First test, wrong 😞

arielgritti
Mega Sage

Hi @Chuck Tomasi 

 

I'm sorry to bother you here. I saw your videos:

  • IntegrationHub Data Stream for Import Data Source - Live Coding Happy Hour for 2021-01-15 (17:38 pagination)
  • Data Stream Actions - Learn Integrations on the Now Platform

One of them is the example: 

totalCount = parseInt(pageResponse.responde_headers(['X-Total-Count']);

 

I have the same situation. In my case, the "token" to decide to get more data is in the response headers, but when I execute the action, it seems response_headers variable is empty.

 

Any idea?

Thanks,

Ariel

Hi @arielgritti 

The correct script is:

Line 5: var totalCount = parseInt(pageResponse.response_headers['X-Total-Count']);
User279787_0-1688509755247.png

 

 Best Regards

Hi @User279787 

I can see a typo in my code (I'll review it) "responde" instead of "response" (I don't know if it was a copy&paste issue when I created my community question) and the brackets and parenthesis use.

 

I'll check and let you know.

Thanks for your answer.

Ariel