Home > Blockchain >  I get status code 200 with postman but with request.get I get status code 500
I get status code 200 with postman but with request.get I get status code 500

Time:05-16

When I make the request in postman to this api https://api.bigauto.solutionslion.com/api/store/showApp sending the parameters = { "part_number": "10-659"} https://ibb.co/QvHvxPw image I get the response correctly https://ibb.co/QvHvxPw

But when doing it in python I get code status 500 as if the parameter was not being sent

import requests

parameters = {
    "part_number": "10-659"
}

response = requests.get("https://api.bigauto.solutionslion.com/api/store/showApp", params=parameters)

print(response.status_code)

CodePudding user response:

Try to use json= parameter instead 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())

Prints:

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",
    }
]

CodePudding user response:

You can try like this.

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)
  • Related