Back to General discussions forum
I'm using the following URL as the endpoint for the task.
http://2.59.218.221/connect4.php
When I send the initial request to the server the response is empty.
params = {"token": user_token}
response = requests.post(ENDPOINT, params=params)
print(response.status_code)
print(response.content)
Output:
200
b"error: Can't detect data format\r\n"
Is the URL I'm using correct?
I identified my issue. I was sending the parameters in the URL query string instead of the post body.
Working code:
def server_request(move=None):
payload = f"token: {USER_TOKEN}"
if move:
payload += f"\nmove: {move}"
return dict(line.split(": ") for line in requests.post(ENDPOINT, data=payload).text.strip().splitlines())