How to Handle a Rest API returning 307 code in Response | Community
Skip to main content
Level 2
November 16, 2023
Question

How to Handle a Rest API returning 307 code in Response

  • November 16, 2023
  • 2 replies
  • 1598 views

Hi,

 

I have a REST API which is being invoked from ACM V7 but in Response we are receiving the Response Code as - 307

Any idea on how to handle the scenario.

It is working fine from Postman.

It is a simple GET request.

 

var url = "***.****************.***/?param=1&param=2";
logInfo(url);
var http = new HttpClientRequest(url);
http.method = "GET";
//http.header["Content-Type"] = "application/json; odata.metadata=minimal";-- tried this if anything make different but did not help anything.
http.execute();
var resp = http.response;
logInfo("resp = http.response : "+resp.toSource()); ----- ({})
var code = http.response.code;
logInfo("Code ="+ code); ------ Code = 307
var bod = http.response.body;
logInfo("body ="+ bod); ---- body = <a href=""> Temporary Redirect</a>[ Tried with this url to make a second http request but not successful.]
var Json_resp = http.response.toString();
//var Json_resp=resp.body;
//var jsonObj = JSON.parse(resp.body); --- tried this but receiving error as the response is not in JSON Format
logInfo("jsonObj = "+ Json_resp); ----  jsonObj = [object HttpClientResponse]

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
November 20, 2023

Hello @souvikg79278577 

 

What are you expecting from this code?

 

To send a new request to the redirected URL? or get the redirect URL itself?

Manoj     Find me on LinkedIn
Sukrity_Wadhwa
Community Manager
Community Manager
December 6, 2023

Hi @souvikg79278577,

Were you able to resolve this query on your own or do you still need help here? Do let us know.

Thanks!

Sukrity Wadhwa