Guest User

Untitled

a guest
Dec 6th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import requests
  2. import sys
  3.  
  4. credential_file_name = "C:\credentials"
  5. with open(credential_file_name, "r") as af:
  6. for line in af:
  7. user = line.split(":")[0].strip()
  8. password = line.split(":")[1].strip()
  9. break
  10.  
  11. url_test = "http://srv190/cmdb/api2/ci"
  12. file_json_test = open(sys.argv[1], "r", encoding="utf-8").read()
  13. headers = {"Content-Type" : "application/json"}
  14. ret = requests.post(url=url_test, json=file_json_test, headers=headers, auth=requests.auth.HTTPBasicAuth( user, password ), verify=False)
  15. print(str(ret.status_code))
  16. print(str(ret.text))
  17. exit(0)
  18.  
  19. 400
  20. {"Message":"The request is invalid.","ModelState":{"ciApi":["An error has occurred."]}}
  21.  
  22. [
  23. {
  24. "name": "test12346",
  25. "description": "test test",
  26. "summary": "Testing CI",
  27. "status": "Active",
  28. "type": "Virtual Server",
  29. "organisation": "IDC"
  30. }
  31. ]
Add Comment
Please, Sign In to add comment