python-3.x pixela API不允许创建图形

cetgtptt  于 2023-02-26  发布在  Python
关注(0)|答案(1)|浏览(105)

我尝试使用Pixela API进行赋值,它允许我创建帐户,但当我调用创建图表时,它一直告诉我用户名不存在或令牌错误,我把他们都设置为常量在顶部,并肯定没有改变他们之间的调用,所以我不知道该怎么办?我想我'在跳过作业之前,我会在这里问一下是否有人能帮忙

import requests

USERNAME = "hoods"
TOKEN = "subarupython!!!"

pixela_endpoint = "https://pixe.la/v1/users"
graph_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs"
user_params = {
    "token": TOKEN,
    "username": USERNAME,
    "agreeTermsOfService": "yes",
    "notMinor": "yes"
}
#Create user account
# response = requests.post(url=pixela_endpoint,json=user_params)
# print(response.text)

graph_config = {
    "id": "graph1",
    "name": "training",
    "unit": "hours",
    "type": "int",
    "color": "sora"
}

header = {
    "X_USER_TOKEN": TOKEN
}

graph_response = requests.post(headers=header, url=graph_endpoint, json=graph_config)
print(graph_response.text)
sxpgvts3

sxpgvts31#

“X_USER_TOKEN”中的下划线需要是连字符。2我已经准备好被取笑了。

相关问题