We'd love to hear about it! Click here to go to the product suggestion community
I am trying to interact with a REST API using the requests library.
I need to pass a large XML file to the API - I can do this easily with curl in Linux but I want a pythonic way to do this.
In curl my syntax looks like this:
curl -k 10.244.1.2:4444/.../APIController -F "reqxml=MYxml.xml"
Note: the -k flag just ignores the ssl error
So far here is what I have come up with:
url = r'10.244.1.2:4444/.../APIController
x = open('MYxml.xml', 'r').read()
q = requests.post(url, data=x, verify=False)
If I change that q variable to this: q = requests.post(url + x, verify=False) then the command will work. Prepaid Gift Balance However, with longer XML files it will fail.
q = requests.post(url + x, verify=False)
I have looked at these two related posts: First, Second but the suggestions look just like my syntax unless I am missing something obvious
Any help is appreciated!