- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 08:18 AM
Hi,
While doing rest call and providing basic authorization, I am getting an invalid username and password combination. I trying to do sailpoint integration and to test whether all the content json and headers work correctly, I used google chrome postman to send the values as Rest and it worked like a charm. But when using ServiceNow, it throws me an error with invalid user name password combination.
I tried to debug further by adding logs to the BasicAuth Script Include and it shows me that the username password it is authorizing is the one configured for MidServer. Though I have not selected the mid server in my rest message it still is using the midserver user name password. Is there a way to make a direct Rest call without using the mid server?
Thanks,
Venkat
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 11:12 AM
Hi Venkat,
This has been recognized as an issue and will be addressed. The workaround is to manually create an "Authorization" header with a value of "BASIC ****". The * value is equal to the base64 encoding of the credentials, username:password.
Here is some sample code to arrive at the encoded credentials.
var username = "my_username";
var password = "my_password";
encodedAuth = GlideStringUtil.base64Encode(username + ':' + password);
gs.print("BASIC " +encodedAuth);
Result -
BASIC bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=
I hope this helps address your concerns.
Regards,
Julio Fernandez
ServiceNow Integrations Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2016 11:12 AM
Hi Venkat,
This has been recognized as an issue and will be addressed. The workaround is to manually create an "Authorization" header with a value of "BASIC ****". The * value is equal to the base64 encoding of the credentials, username:password.
Here is some sample code to arrive at the encoded credentials.
var username = "my_username";
var password = "my_password";
encodedAuth = GlideStringUtil.base64Encode(username + ':' + password);
gs.print("BASIC " +encodedAuth);
Result -
BASIC bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=
I hope this helps address your concerns.
Regards,
Julio Fernandez
ServiceNow Integrations Team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 02:25 AM
Hi Julio,
We are trying to integrate ServiceNow with a 3rd Party system using the Rest API.
(We are working on Istanbul version of ServiceNow)
The API supports an Authentication token for Post, Put, Delete requests.
From ServiceNow, we are able to generate the token via a Get request to get the login session.
However, any subsequent request after the Get request gives us a 401 Unauthorized error.
Here is the sample code we are running on ServiceNow for the Post request:
var username = 'username';
var password = 'password';
var authcode = GlideStringUtil.base64Encode(username + ':' + password);
r.setEndpoint('https://some post uri');
r.setRequestHeader('Accept','application/json');
r.setRequestHeader('Content-Type','application/json');
r.setRequestHeader('Authorization','Basic '+authcode);
The response we get is:
HTTP Status: 401 Unauthorized
Error: Error Code: 3 Error Message: Method failed: (the post URI) with code: 401 - Invalid username/password combo
The same request when hit using PostMan, we get the required results.
Please suggest on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 02:29 PM
Hi Megha,
Were you able to get to the bottom of this? If you print out the Authorization header it should give you an idea of what is amiss.
Take care.
Julio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 03:55 PM
Hi Megha,
I dont see the var r = new sn_ws.RESTMessageV2('API name', 'method name') but i believe you might have had it. If that is the case, does that Rest API method have the user name and password defined in it. We need authorization header apart from User name /Password defined in that API.