Unauthorized to send REST API requests on incident table

sovanna
Mega Contributor

Hi,

I'm trying to test the REST API in order to send requests on the incident table.

Each day I create a test user with the "rest_service" profile on Service Now's sandbox :   ServiceNow

I was able to create incidents successfully for 2 days.

But now I get the following error in RESTClient

  1. Status Code: 401 Unauthorized
  2. Connection: close
  3. Content-Encoding: gzip
  4. Content-Type: application/json
  5. Date: Fri, 09 Jan 2015 15:54:02 GMT
  6. Server: ServiceNow
  7. Transfer-Encoding: chunked
  8. WWW-Authenticate: BASIC realm="Service-now"

Thanks,

Sovanna

1 ACCEPTED SOLUTION

Works fine on this instance!


Thanks Hari!


View solution in original post

8 REPLIES 8

Use one of the demo instances:-



URL: https://demo006.service-now.com/login.do


username:admin


password:admin



Create a user profile with rest_service,itil roles. Try the post method onto this instance. See if it works.



Regards,


Hari


Works fine on this instance!


Thanks Hari!


no problem .would you mind closing off this thread please.


I'm getting 401 Unauthorized error too when using API in development instance (Helsinki). Under roles, rest_service role description says "Deprecated. This role is no longer required to access the REST API." When creating the user I'm using to connect, I did make sure it has "Web service access only" checkbox checked.


               $(document).ready(function () {                         //get token                                               var snOauthClientId = 'my_client_id';                         var snOauthSecret = 'my_secret';                         $.ajax({                                 url: 'https://dev_instance.service-now.com/oauth_token.do?grant_type=password&client_id=' + snOauthClientId + '&client_secret=' + snOauthSecret,                                 type: 'POST',                                 dataType: 'jsonp',                                 success: function (data) { authToken = 'somevalue'; console.log(JSON.stringify(data)); },                                 beforeSend: setHeader,                                 error: function () { alert('Failed!'); }                         });                 });                   function setHeader(xhr) {                         var snRESTUser = 'username';                         var snRESTPwd = 'password';                         xhr.setRequestHeader("Authorization", "Basic " + btoa(snRESTUser + ":" + snRESTPwd));                         xhr.setRequestHeader('Accept', 'application/json');                         xhr.setRequestHeader('Content-Type', 'application/json');                 }