Home > Blockchain >  How to send '-X POST' using 'requests' library in Python?
How to send '-X POST' using 'requests' library in Python?

Time:08-24

I am trying to replicate shell command:

curl -u [staff_email]:[api_key] -F "case[attachments][0]=@/path/to/file1.ext" -F "case[attachments][1]=@/path/to/file2.ext" -F "case[content]=I need help" -F "case[subject]=I need help" -F "case[user_email][email protected]" -F "case[user_full_name]=FullName" -F "case[language_id]=2" -F "case[custom_fields][cf_44]=3" -X POST https://[domain].omnidesk.ru/api/cases.json

into Python code using Requests library:

import requests

What is a proper syntax for this example (curl -X POST)?

CodePudding user response:

You can use requests.post, as explained here

for the attachments part (your first -F), read here

for the auth part (-u): here

  • Related