Rest Message Authorization

venkatiyer1
Giga Guru

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

1 ACCEPTED SOLUTION

SDJulio
ServiceNow Employee
ServiceNow Employee

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


View solution in original post

14 REPLIES 14

Were you able resolve your issue, We are having the exact same issue


Community Alums
Not applicable

Hi,


We are facing the same issue when calling the import set table in Servicenow from outside while integrating to SAP, anybody was able to resolve this error.


401 user authetication.


<?xml version="1.0" encoding="UTF-8"?>


<response>


      <error>


              <detail>Required to provide Auth information</detail>


              <message>User Not Authenticated</message>


      </error>


      <status>failure</status>


</response>



Regards,


Raushan


Solved the issue in flow designer rest step by using 'Basic' instead of 'BASIC', 'BASIC' was causing the 401 error 

Hi Julio, 

Could you please confirm if this issue has been resolved as we are still experiencing the same issue while trying to connect to a third party application using the REST Post method? 

 

If it's not yet resolved, where should I use the above code as a workaround?

Thanks, 

Rohit

Solved the issue in flow designer rest step by using 'Basic' instead of 'BASIC', 'BASIC' was causing the 401 error