I get an error message (HTTP Error) 400 when trying to create a graph. The user has been successfully generated, as can be seen from the below message:
import requests
USERNAME = "testusermichael"
TOKEN = "2ködfajfölN!!"
GRAPH_ID = "graph1"
pixela_endpoint = "https://pixe.la/v1/users"
user_params = {
"token": TOKEN,
"username": USERNAME,
"agreeTermsOfService": "yes",
"notMinor": "yes",
}
graph_endpoint = f"{pixela_endpoint}/{USERNAME}/graphs"
graph_config = {
"id": GRAPH_ID,
"name": "Walking Graph",
"unit": "Km",
"type": "float",
"color": "shibafu"
}
headers = {
"X-USER-TOKEN": TOKEN
}
response = requests.post(url=graph_endpoint, json=graph_config, headers=headers)
print(response.text)
response from trying to create the user again:
{
"message": "This user already exist.",
"isSuccess": false
}
response from trying to create a graphic
{
"message": "User testusermichael does not exist or the token is wrong.",
"isSuccess": false
}
As per the comment discussion, it seems the API doesn't like some characters in the token. This might be due to character encoding, or the simple fact that it doesn't really accept non-alphanumeric tokens.
Fix is quite simple, which is to use a simple alphanumeric token. Since the length can be up to 128.
Use something like this site to generate a long token and use that to authenticate the other requests