- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2018 08:06 AM
Hi,
I'm trying to solve an issue I am having with a REST message. The following is the REST Message configuration/setup:
var hostName = 'test.hostname.com';
var request = new sn_ws.RESTMessageV2('System Information', 'POST SiteToken');
request.setStringParameter('baseUrl','test.hostname.com');
//request.setStringParameter('baseUrl',hostName);
request.setStringParameter('api','15.8');
request.setRequestHeader('Accept','application/json');
request.setRequestHeader('Content-Type','application/json');
//request.setStringParameter('siteID','ae0377db-5dc5-4f31-aea2-f');
var response = request.execute();
This is the REST Message endpoint:
https://${baseUrl}/api/${api}/auth/signin
When I run the rest request it passes successfully, http=200, and I get the correct information back
When I run the request with the hostname as a variable:
request.setStringParameter('baseUrl',hostName);
Then the request fails with error message: unknown host.
I have done some troubleshooting with Xplore and there when using the hostname variable in the request and do:
gs.print("Set Endpoint: " + sm.getEndpoint());
it returns the correct endpoint:
test.hostname.com
Any idea on why this fails when using a variable in the REST message setup?
Thank you,
Roland
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2018 08:19 AM
Hello,
It looks weird but just a try to cast the variable to a String with double quotes.
var hostName = "test.hostname.com";
Can you make this change and see if it works. I have seen some posts where the double quotes have messed up.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2018 08:19 AM
Hello,
It looks weird but just a try to cast the variable to a String with double quotes.
var hostName = "test.hostname.com";
Can you make this change and see if it works. I have seen some posts where the double quotes have messed up.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2018 12:15 PM
Hi Alikutty,
Thank you that solved the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2018 05:48 PM
Great!! Can you please mark my response as correct answer and close this thread?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2018 08:51 AM
I think you have marked the wrong response as correct answer. Can you please mark my first response as correct answer so the community users can refer to it?