Next I put a fragment of the code with which I was working (I am a newbie) and I have a query. I get the token correctly but when I want to use the API "save response", it tells me error 500 and apparently, as I understand it, it is an error in the creation of headers or data. Could you guide me how I can solve it? I never worked with Python and less with APIS. I understand what GET PUT DELETE POST are, but I do not have much idea about data handling ...
import requests
import json
url = 'http://qualytwebopinator-dev.us-east-
1.elasticbeanstalk.com/connect/token'
payload = {'machineId': 'prueba1234', 'password': 'xxxxxx'}
response = requests.post(url, json=payload)
token = None
if response.status_code == 200:
token = response.json() # Token
token = token['token']
print (token)
url = 'http://qualytwebopinator-dev.us-east-
1.elasticbeanstalk.com/api/Response/GuardarRespuesta'
headers = {"Content-Type" : "application/json", "authorization" : "Bearer
"+token}
data = {'machine Id': '123', 'date': '2018-10-29T11:36:31.131Z',
'responseId': 'xxx', 'mark': '1'}
r = requests.put(url, data=data, headers=headers)
print ("\n"+ str(r.status_code)) # ME DEVUELVE 500
The instructions are as follows:
The idea is to first log in with the api link
There is a test username and password, MachineId and Password respectively
This returns a token that I should include in the other apis through the> header. Token lasts 24 hours and then I must return to log it.
Then there are the two apis / api / Response / SaveResponse and > / api / Response / SaveSound The idea is that first the response passes and then the sound.
If you can guide me because of what this 500 status can be, I will thank you very much. Thanks in advance