import urllib.request import json data = { "Inputs": { "input1": [ { 'august': "1", } ], }, "GlobalParameters": { } } body = str.encode(json.dumps(data)) url = 'https://ussouthcentral.services.azureml.net/workspaces/66e373b2084d4ffa9395c0e34ce9ccaa/services/7a5b738fb04c4661987577c18b581d89/execute?api-version=2.0&format=swagger' api_key = 'k6wS1QFvNJlm5wAm3Lr2h+vz346ltLOeNqUvIeYBHTpdV2Za/u27JChvztHtJTZ8sXuCU3X8Dy5kye0exxlHMA==' # Replace this with the API key for the web service headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)} req = urllib.request.Request(url, body, headers) #kysige augusti suurus kasutajalt try: response = urllib.request.urlopen(req) result = response.read() #print(result) obj=json.loads(result.decode("utf-8")) print(obj["Results"]["output1"][0]["septembriennustus"]) except urllib.error.HTTPError as error: print("The request failed with status code: " + str(error.code)) # Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure print(error.info()) print(json.loads(error.read().decode("utf8", 'ignore')))