skip to Main Content

Json – Powershell: Using Invoke-WebRequest with variables

I am currently having a problem with a script to send fuel transactions through an api. It works without variables: $headers=@{} $headers.Add("accept", "application/json") $headers.Add("content-type", "application/json") $headers.Add("authorization", "$APIToken") $response = Invoke-WebRequest -Uri 'https://api.samsara.com/fuel-purchase' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"fuelQuantityLiters":"676.8","iftaFuelType":"Diesel","transactionLocation":"350…

VIEW QUESTION

Json – Get specific content from facts API Python

This is my current code: limit = 1 api_url = 'https://api.api-ninjas.com/v1/facts?limit={}'.format(limit) response = requests.get(api_url, headers={'X-Api-Key': API_KEY}) print(response.text) I get this returned: [{"fact": "The Canadian province of New Brunswick had a bloodless war with the US state of Maine in 1839"}]…

VIEW QUESTION
Back To Top
Search