未通过请求 API 获得响应
当我直接传递整数值时,我从 API 得到了正确的响应,但当我通过变量传递整数时,我没有得到任何响应。
# Extarct information of Metadata of Design id-5071431
import requests
url = "https://www.helioscope.com/api/designs/5071431"
payload={}
headers = {
'access_token': 'API_key',
}
response = requests.request("GET", url, headers=headers, data=payload)
# <Response [200]>
des=5071431
# Extarct information of Metadata of Design id-5071431
import requests
url = "https://www.helioscope.com/api/designs/{des}"
payload={}
headers = {
'access_token': 'API_key',
}
response = requests.request("GET", url, headers=headers, data=payload)
# <Response [500]>
随附的是同一屏幕截图
提前致谢
I am getting proper response from API when I am passing integer value directly but I am not getting any response when I am passing integer through variable.
# Extarct information of Metadata of Design id-5071431
import requests
url = "https://www.helioscope.com/api/designs/5071431"
payload={}
headers = {
'access_token': 'API_key',
}
response = requests.request("GET", url, headers=headers, data=payload)
# <Response [200]>
des=5071431
# Extarct information of Metadata of Design id-5071431
import requests
url = "https://www.helioscope.com/api/designs/{des}"
payload={}
headers = {
'access_token': 'API_key',
}
response = requests.request("GET", url, headers=headers, data=payload)
# <Response [500]>
Attached are the screenshots for the same
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
response.text
将显示服务器响应正文{des}
应替换为实际 ID,就像您在第一个请求中所做的那样您没有使用 f 字符串将任何变量加载到字符串中,因此它被视为文字。你也可以在最后连接
response.text
will show the server response body{des}
should be replaced with an actual ID like you did in the first requestYou're not using an f-string for loading any variables into the string, so it's taken as a literal. You could also just concatenate at the end