Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #Need to install requests package for python
  2. #easy_install requests
  3. import requests
  4.  
  5. # Set the request parameters
  6. url = 'https://dev20467.service-now.com/api/now/table/u_cardata'
  7.  
  8. # Eg. User name="admin", Password="admin" for this code sample.
  9. user = 'admin'
  10. pwd = 'admin'
  11.  
  12. # Set proper headers
  13. headers = {"Content-Type":"application/json","Accept":"application/json"}
  14.  
  15. # Do the HTTP request
  16. response = requests.post(url, auth=(user, pwd), headers=headers ,data="{'u_source':'Test'}")
  17.  
  18. # Check for HTTP codes other than 200
  19. if response.status_code != 200:
  20. print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
  21. exit()
  22.  
  23. # Decode the JSON response into a dictionary and use the data
  24. data = response.json()
  25. print(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement