I use requests library. Here is the code that works fine with API (creation of CIs):
201
{"id":6220,"self":"http://idcsrv190/cmdb/api2/ci/6220"}
The code "201" is the successfully created record. I can select it from the browser. There is no explicit commitment.
I add html page of the screen with the CI details on the next post. I do not see the way to attach file here.
The HTML file in line 162 has a form (<form action="/cmdb/ci/save") to save CI details. I think this is what I need to update and upload from my python script, but do not know how. The link /cmdb/ci/save doe not use API and sends information directly to the web server.
CodePen
url_cmdb_test = "http://idcsrv190/cmdb/api2/ci" user,password = get_name_and_password( credential_file_name ) report_json_to_file = os.path.normpath(os.path.join(os.getcwd(),"test-ci_2.json")) file_json_test = open(report_json_to_file, "r", encoding="utf-8").read() headers = {"Content-Type" : "application/json;charset=utf-8"} ret = requests.post(url=url_cmdb_test, data=file_json_test, headers=headers, auth=requests.auth.HTTPBasicAuth( user, password ), verify=False) print(str(ret.status_code)) print(str(ret.text))Here is one of the latest outputs:
201
{"id":6220,"self":"http://idcsrv190/cmdb/api2/ci/6220"}
The code "201" is the successfully created record. I can select it from the browser. There is no explicit commitment.
I add html page of the screen with the CI details on the next post. I do not see the way to attach file here.
The HTML file in line 162 has a form (<form action="/cmdb/ci/save") to save CI details. I think this is what I need to update and upload from my python script, but do not know how. The link /cmdb/ci/save doe not use API and sends information directly to the web server.
CodePen