Dynamically created RESTMessageV2 and oauth authentication
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello
We have some code that dynamically creates and adds the necessary(?) parameters to a RESTMessageV2 objects. This includes an oauth2 authentication profile. The problem is that when executes the REST request no authentication data is added to the request. We can see that the header contains Authorization=null and that no oauth authorization request are performed. If we change the request to a statically defined REST message (sys_rest_message) with the same oauth profile, the authorization works as expected. Here is a simple code snippet we have used to try to figure out what the problem might be:
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod("get");
restMessage.setEndpoint(<endpoint URL>);
restMessage.setAuthenticationProfile('oauth2', '59d3d984b597c71032949b08bd99ee00');
restMessage.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
var response = restMessage.execute();
responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
status = response.getStatusCode();
gs.info("status=" + status + ", responseBody=" + responseBody);This example fails as described above (ie no oauth authorization is performed).
