Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import sys
- credential_file_name = "C:\credentials"
- with open(credential_file_name, "r") as af:
- for line in af:
- user = line.split(":")[0].strip()
- password = line.split(":")[1].strip()
- break
- url_test = "http://srv190/cmdb/api2/ci"
- file_json_test = open(sys.argv[1], "r", encoding="utf-8").read()
- headers = {"Content-Type" : "application/json"}
- ret = requests.post(url=url_test, json=file_json_test, headers=headers, auth=requests.auth.HTTPBasicAuth( user, password ), verify=False)
- print(str(ret.status_code))
- print(str(ret.text))
- exit(0)
- 400
- {"Message":"The request is invalid.","ModelState":{"ciApi":["An error has occurred."]}}
- [
- {
- "name": "test12346",
- "description": "test test",
- "summary": "Testing CI",
- "status": "Active",
- "type": "Virtual Server",
- "organisation": "IDC"
- }
- ]
Add Comment
Please, Sign In to add comment