The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Getting Error when trying to get access token using REST API

rakesh_mishra
Giga Contributor

Hi,

I am getting below error when my customer is trying to generate access token.

Error : no json object could be decoded.

this error he has sent me using screen shot, and i can't access the log lines also?

when i am trying using my servicenow account it's giving the access token.

Can any one please help me for the same.

here is my python code.

data = {}

data['client_secret'] = client_secret

data['client_id'] = client_id

data['grant_type'] = grant_type

data['username'] = username

data['password'] = password

try:

                      response = requests.request(method='POST', url=utility.TOKEN_URL.format(instance_name), data=data)

except requests.HTTPError as re:

                      _errormsg = {}

                      _errormsg['error_code'] = re.response.status_code

                      if re.response.status_code == 401:

                              raise Exception('Error: Either the credentials provided are invalid or {} does not have the required privileges. Please check your credentials and configuration and try                                                                       again.'.format(username))

                      _errormsg['error_description'] = re.response.text

                      raise Exception(_errormsg)

response = json.loads(response.text)

return response

I think its not able to decode using   json.loads, but i don't know what error it's giving , can any one help me for the same.

1 ACCEPTED SOLUTION

Geoffrey2
ServiceNow Employee
ServiceNow Employee

Actually your 403 error looks like an IP restriction. Check with the ServiceNow admin to see if they need to allow the IP 43.242.244.50


View solution in original post

6 REPLIES 6

Geoffrey2
ServiceNow Employee
ServiceNow Employee

Actually your 403 error looks like an IP restriction. Check with the ServiceNow admin to see if they need to allow the IP 43.242.244.50


Thanks Geoffrey Sage ,



Yes customer restricted the IP of my organization ,


thank you very much