Expand my Community achievements bar.

How to Handle a Rest API returning 307 code in Response

Avatar

Level 2

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]

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

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

Avatar

Administrator

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