0

I am trying to post/put to Sheety via Python:

SHEETY_URL = "https://api.sheety.co/gfhgfhjfdghjgfjf/flightDeals/prices/5"

header = {
    "Content-Type" : "application/json"
}
params_sheety = {
    "price": {
        "iataCode": "PLN"
    }
}
response_sheety = requests.put(url=SHEETY_URL, params=params_sheety, headers=header)
print(response_sheety)
print(response_sheety.json())

=======================================================

Getting Bad request Error:

<Response [400]> {'errors': [{'detail': "Bad Request. The JSON payload should be inside a root property called 'price'. Check https://sheety.co/docs for more details."}]}

The same request works fine with Postman.

Postman

Pawel Kam
  • 1,684
  • 3
  • 14
  • 30
Svit
  • 3
  • 2

1 Answers1

0

When you use params=params_sheety, the parameters are not sent as json.

Use json=params_sheety to send them as json.

This also sets the content-type header to json automatically, so you don't need headers=header.

John Gordon
  • 29,573
  • 7
  • 33
  • 58
  • Then I get – Svit Feb 19 '23 at 18:09
  • Traceback (most recent call last): File "c:\users\shromivchuk\appdata\local\programs\python\python311\lib\site-packages\requests\models.py", line 971, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ – Svit Feb 19 '23 at 18:10
  • 524 appears to be a timeout. Perhaps this is a firewall issue? Is this code running on the same computer where you run postman? – John Gordon Feb 19 '23 at 20:02
  • the same computer – Svit Feb 19 '23 at 21:15
  • It works now, passing it as json solved the issue, I just messed up with the url thats why it had returned the 524 – Svit Feb 19 '23 at 21:27