- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2021 09:15 AM
Hi all,
I'm trying to call a REST API and it needs two different step: the first one to get an access token, the second one to do the REST call.
I'm able to do the first one, in fact I'm getting the access token correctly.
The problems come with the second one, because I need to get cookies and token from the first call and pass them to the 2nd.
I'm able to pass the access token in header with setRequestHeader(string Name, string Value), but I can't reach to correctly set cookies in the 2nd REST call. Here the code used for the 2nd call:
//"token" contains token from the first call
var r = new sn_ws.RESTMessageV2('Create user', 'POST');
var body = '';
r.setRequestHeader('X-CSRF-Token', token.toString());
/***** BODY START *****/
body += '{\n';
body += '......';
body += '}\n';
/***** BODY END *****/
r.setRequestBody(body);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
However I don't know how to use setCookies() or a similar function to correctly pass the cookies when doing POST REST call.
Could please anyone help me?
Thanks!
Simone
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2021 08:53 AM
Hi all,
in the end we manage to remove the access token from the third-party application and chanage auth type for the 2nd call (without an access token).
Thanks for your replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2021 08:53 AM
Hi all,
in the end we manage to remove the access token from the third-party application and chanage auth type for the 2nd call (without an access token).
Thanks for your replies
