Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripted update of web page
#3
I use requests library. Here is the code that works fine with API (creation of CIs):

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
Reply


Messages In This Thread
Scripted update of web page - by treatitwell - Jan-05-2018, 09:07 PM
RE: Scripted update of web page - by wavic - Jan-06-2018, 12:16 AM
RE: Scripted update of web page - by treatitwell - Jan-06-2018, 01:27 AM
RE: Scripted update of web page - by treatitwell - Jan-06-2018, 03:06 AM
RE: Scripted update of web page - by wavic - Jan-06-2018, 03:16 AM
RE: Scripted update of web page - by treatitwell - Jan-06-2018, 03:19 AM
RE: Scripted update of web page - by snippsat - Jan-06-2018, 02:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,652 Mar-19-2020, 06:13 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020