curl - using testrail api in python script -


i have curl command, not sure how run in python script.

curl -h "content-type: application/json" -u "username:password" -d '{ "name":"something" }' "https://xxxxxxxx" 

i'm planning use subprocess, api documents aren't helpful.

also know how sectionid testrail?

you want use requests package this. curl command translates this:

import json import requests  response = requests.post('https://xxxxxxxx',                          data=json.dumps({'name': 'something'}),                          headers={'content-type': 'application/json'},                          auth=('username', 'password')) response_data = response.json() 

if want use subprocess, can this:

import subprocess  curl_args = ['curl', '-h', 'content-type: application/json', '-u', 'username:password',              '-d', '{ "name":"something" }', 'https://xxxxxxxx'] curl_output = subprocess.check_output(curl_args) 

i consider latter approach less "pythonic".


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -