- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2020 10:28 AM
Hi,
I'm trying to connect to a third party with Rest Message and Basic Auth, but when I try to test the connection, the rest of the message returns a "401 - Invalid username / password combo" error, but if I go into the core server, I open a browser and put the end point in url and I put the user / end point returns a JSON.
My question is what am I doing wrong? Why on the server can I access the endpoint and from servicenow I don't have access? when I do a test on the rest message with the related link "Test", the response body returns 'You do not have permission to view this directory or page'.
The Http header and Http query is empty.
Also I have tried this:
https://community.servicenow.com/community?id=community_question&sys_id=29658baddbd8dbc01dcaf3231f961972&view_source=searchResult
And i have the same result.
Thanks,
Jonay
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 12:05 AM
Hi,
The proble have been resolved with this workarround: https://hi.service-now.com/kb_view.do?sysparm_article=KB0778973
Thanks,
Jonay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2020 02:55 PM
Not sure about the question. Is the question about getting authentication error when trying to connect to the third party on-premise service using a script generated by REST Message tool? There's no error when the service is accessed from ServiceNow web page?
If so, the most likely reason is MID server not being specified in the generated script. It's necessary to edit the following line in the generated script to specify the MID server to use.
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2020 11:55 PM
Thanks for your answer.
No, the question is not how to get that error. I get that error when I launch a connection test from servicenow. But if I log into the server and open a browser if I get a JSON response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 04:39 AM
Please provide the code that's generating the error. There's no error when logging into ServiceNow because the credentials are provided during the login.
The code probably isn't providing the correct credentials. Can't say where without looking at the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2020 02:15 AM
Hi,
Thanks for your answer.
The code it is OOTB:
var r = new sn_ws.RESTMessageV2('IN*****', 'getHardware*****');
//override authentication profile
//authentication type ='basic'/ 'oauth2'
r.setAuthenticationProfile('basic', 'd22f0797db42d4******0a1ca9619e6');
//set a MID server name if one wants to run the message on MID
r.setMIDServer('SNCSM*******');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.print(responseBody);
And the responsebody return this:
But, if I enter to the server and open one navegator and go to the end point and put the auth basic and return with one file download with the JSON.