[Python] Trying to write output from shell command to JSON file using python

Discussão em 'Python' iniciado por Stack, Novembro 22, 2025.

  1. Stack

    Stack Membro Participativo

    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")


    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 same domain name and api_key not sure why i am getting 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('username@gmail.com', 'password@')
    response = requests.get(url,headers=headers,auth = authParams)


    Any help would be appreciated.

    Continue reading...

Compartilhe esta Página