Extracting response headers
When making requests using a CallRESTEndpointFNC , responses are returned along with the ResponseHeaders
list in the form of:
[
{
"Name":"string",
"Value":"string"
}
]
The structure of the
Header
list when hosting and receiving requests is different, find out more hereOften, information is returned in these header values for subsequent use, values such as location
are passed in headers for use in sub-sequent requests involving pagination.
CallRESTEndpoint: Response Headers:
Transfer-Encoding = chunked
Connection = keep-alive
Access-Control-Allow-Origin = *
Access-Control-Allow-Methods = GET
Vary = User-Agent
CF-Cache-Status = DYNAMIC
cf-request-id = 06c048ffb00000077a8425d000000001
Report-To = {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=8xScWvUIuL00gAIkoquwi%2Blpa5f6Up4XZjtkzO3kyGqv54RZC%2FtW7dzUZviJOnKsC6aM4Gq75bKrZieJxI5yUcG2xKwiLNIwZMYta0FY"}],"group":"cf-nel","max_age":604800}
NEL = {"report_to":"cf-nel","max_age":604800}
CF-RAY = 5fad777919b9077a-LHR
Cache-Control = must-revalidate, no-cache
Date = Tue, 01 Dec 2020 14:23:33 GMT
Set-Cookie = __cfduid=d770f214e0e521e7d5e82a489e3f68d1b1606832613; expires=Thu, 31-Dec-20 14:23:33 GMT; path=/; domain=.icndb.com; HttpOnly; SameSite=Lax
Server = cloudflare
Content-Type = application/json
Expires = Sat, 26 Jul 1997 05:00:00 GMT
Content-Length = 167
Although you can see the full list of header
values in the Debug Values panel like below:
In order to access header
items within the list, there are 2 approaches:
-
Use a ForEachFNC and loop through the
CallRESTEndpoint.ResponseHeaders
list.On each loop use an IfElseFNC to evaluate if the current loop value’s
Name
field matches your search term.
If it does, then use the value of
ForEach.Loop.Value
. -
Use the below expression to extract the needed value
= CallRESTEndpoint.ResponseHeaders.Where(headerItem => headerItem.Name == "SearchTerm").FirstOrDefault().Value
As you can see the second approach is much cleaner, although it requires an understanding of expressions.
Take a look at the below sample Solution to give you a practical demonstration.
Solution (.lsoz) (6.2 KB)