- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 03:33 PM
Hi Everyone i was trying to create a change using the Servicenow API but I'm getting the following error.
My Code :-
import requests
url="https://******.service-now.com/api/now/table/change_request"
user="***"
password="*****"
headers={"Content-Type":"application/json","Accept":"application/json"}
response = requests.put(url, auth=(user, password), headers=headers ,data="<request><entry><assignment_group>testgroup</assignment_group><category>prod</category><requested_by>user1</requested_by><type>comprehensive</type></entry></request>")
print(response.status_code)
#print(response.json())
The Error which I'm getting:-
Traceback (most recent call last):
File "****\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "******\Python\Python36-32\lib\site-packages\urllib3\util\connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "*******\Python\Python36-32\lib\socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
When i'm executing request with **get** it's working fine printing the status code of 200 but when i use with **.put** and **data** it's throwing error.
response=requests.get(url,auth=(user,password),headers=headers)
Can you please help me...
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 05:15 PM
Try using POST. I tried below and it works.
POST https://XXX.service-now.com/api/now/table/change_request
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 05:15 PM
Try using POST. I tried below and it works.
POST https://XXX.service-now.com/api/now/table/change_request
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 05:17 PM
Also FYI, put is only used for updating existing records
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 12:56 AM
Hi Sanjiv,
Thanks for Helping I'll Try and will let you know by tonight as I am at work and there is no environment for testing here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2018 03:52 AM
Hi Sanjiv,
I checked with post