Skip to content
Advertisement

Python missing data in body

Hello i’m using request to perform some http calls. The is a strange behaviour, the response should contain a list of items, but i only get one item.

This is the result i get from Postman when performing the call:

JavaScript

With this is the reponse i get in my script :

JavaScript

this is how i perform the action :

JavaScript

it’s like it returns only the last element. I could not figure out why.

EDIT added request:

JavaScript

Advertisement

Answer

I found the problem and then the solution. Going deep reading https://docs.python-requests.org/en/latest/user/quickstart/#make-a-request, instead of giving a JSON ojbect i could send a string payload that encodes a JSON. So my code now is :

JavaScript

and return the list of items correctly, i’ve added an header : 'Content-Type': 'application/json; charset=Latin-1 because i need it later.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement