I am trying to write output from API request (passing through shell command) to JSON file using Python.
import os
assignments = os.system("curl -u https://apitest.com/api/-u domain:jsdjbfkjsbdfden")
I'm getting a response in string format. How I can save this response to a JSON file?
I tried with the request library in Python with the same domain name and api_key, and I'm not sure why I get a 404 error {"error":"Invalid api id. Verify your subdomain parameter"}
import requests
from requests.auth import HTTPBasicAuth
url = "https://apitest.com/api/"
headers = {"SUBDOMAIN":"domain","api_key": "jsdjbfkjsbdfden"}
authParams = HTTPBasicAuth('[email protected]', 'password@')
response = requests.get(url,headers=headers,auth = authParams)