Hello,
I am facing one issue. When I am opening postman and switching OFF “Automatically follow redirects” from settings, calling the API , I am getting headers in response (say 5 headers as showin in 2nd image). When it is ON , it gives different response headers(say 13 headers). I want to get the Location key which has URL. But this header response is not coming when the automatically follow redirects is ON .
When I am consuming the REST API in outsystems and using onafterresponse , I am getting 13 headers in response (which in POSTMAN I get if automatically follow redirects is ON) but I want another set of response header i.e. 5 . so how we can off this “automatically follow redirects” in outsystems?
Thanks,
Tejas
Update on this thread
It seems you'll need to create a simple piece of code in .NET and use it using the AdvancedOnAfterResponse.
More info here:
Hi Tejas,
I'm having a hard time understanding the use case here.
From what I understand you want to get the value in the Location Header and then do something with it, the problem is that when consuming the API in OutSystems that header is not available in the OnAfterResponse HTTP Header list.
Is that it?
edited for clarity
Yes correct, Location header is not available, there are some other sets of headers are available and coming in "on after response". The reason is outsystems by default taking the other set of headers. In Postman if you try and hit the end-point you will get these differenet set of headers when your "automatic follow redirects" option is ON.
And when it is OFF, you will get Location header and other 3 headers with it. I can get both set of headers in post man but not in outsystems.
Ok, got it.
Have you changed the logging level of that API to "Full" and check if the headers are logged?
I'm not aware of OutSystems removing any headers, the only thing that comes up as cause could be that the API method requires a specific input or Header before making the Request to later have the Location header in the response. Is this a public API that I can experiment with?
Hi @Cristiana Umbelino ,Thank you for the suggestion. I have checked the logging level of the API and they are already in "Full" level. PSB the image for the same. It is not public API so can't share the details with you.Let me know if you get any intel over it.
Can you confirm that the HTTP Response Code is a 3xx?
Asking because of the definition of the Automatically follow redirects setting.
Automatically follow redirects: Turn off this toggle to prevent requests that return a 3xx series response from being automatically redirected.
Thank you @Cristiana Umbelino . This is really helpful. I will surely try this one and create one component in order to overcome this issue.
Hi @Tejas Mendse ,
Have you managed to get this to work as you intended? Preventing outsystems to auto redirect?
Hi everyone,
Happened to come across this issue again and just wanted to share that the Platform automatically does the redirect for you and the response will be the same as if you do a GET to the Location header value.
In my case, I was trying to get the Location header value so that I could get a file from that URL. After a bit of tinkering around, I figured that the response already was the binary of the file I was looking for. In this case, I only had to change the output of the REST API method to Binary and I would get the file without any more coding.
In case you still need the URL in the Location header, I think you still need to use that .NET property mentioned above.