我得到邮递员的状态代码 200 但 request.get 我得到状态代码 500
I get status code 200 with postman but with request.get I get status code 500
当我在邮递员中向这个 api https://api.bigauto.solutionslion.com/api/store/showApp
发送请求时 parameters = { "part_number": "10-659"}
https://ibb.co/QvHvxPw 图片
我得到正确的回应
https://ibb.co/QvHvxPw
但是在 python 中执行此操作时,我得到代码状态 500,就好像没有发送参数一样
import requests
parameters = {
"part_number": "10-659"
}
response = requests.get("https://api.bigauto.solutionslion.com/api/store/showApp", params=parameters)
print(response.status_code)
尝试使用 json=
参数代替 params=
:
import requests
parameters = {"part_number": "10-659"}
response = requests.get(
"https://api.bigauto.solutionslion.com/api/store/showApp", json=parameters
)
print(response.status_code)
print(response.json())
打印:
200
[
{
"id": 78399,
"make": "FORD",
"make_id": 78,
"years": [1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994],
"model": "F-250",
"model_id": 352,
"engine_id": "null",
"cilinders": "null",
"liters": "null",
"valves": "null",
"description": "null",
"fuel": "null",
}
]
你可以这样试试
import requests
import json
url = "https://api.bigauto.solutionslion.com/api/store/showApp"
payload = json.dumps({
"part_number": "10-659"
})
response = requests.get(url, data=payload)
print(response.status_code)
当我在邮递员中向这个 api https://api.bigauto.solutionslion.com/api/store/showApp
发送请求时 parameters = { "part_number": "10-659"}
https://ibb.co/QvHvxPw 图片
我得到正确的回应
https://ibb.co/QvHvxPw
但是在 python 中执行此操作时,我得到代码状态 500,就好像没有发送参数一样
import requests
parameters = {
"part_number": "10-659"
}
response = requests.get("https://api.bigauto.solutionslion.com/api/store/showApp", params=parameters)
print(response.status_code)
尝试使用 json=
参数代替 params=
:
import requests
parameters = {"part_number": "10-659"}
response = requests.get(
"https://api.bigauto.solutionslion.com/api/store/showApp", json=parameters
)
print(response.status_code)
print(response.json())
打印:
200
[
{
"id": 78399,
"make": "FORD",
"make_id": 78,
"years": [1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994],
"model": "F-250",
"model_id": 352,
"engine_id": "null",
"cilinders": "null",
"liters": "null",
"valves": "null",
"description": "null",
"fuel": "null",
}
]
你可以这样试试
import requests
import json
url = "https://api.bigauto.solutionslion.com/api/store/showApp"
payload = json.dumps({
"part_number": "10-659"
})
response = requests.get(url, data=payload)
print(response.status_code)