Reputation: 66
I am making a simple GET request, when these requests are made through postman I get the full response. However, when making the same requests via Python using requests lib I only get a single instance of object "user". The exact same code works jsut as expected when going to one of their other endpoints.
Postman result:
{
"user": {
//...
},
"user": {
//...
},
//...
}
Python response.json():
{
"user": {
//...
}
}
Code:
url = 'my_url'
auth = ('user', 'pass')
response = requests.get(url, auth=auth)
return response
I have walked through the response and URL is exact same as when I get the full response from Postman. Not sure what Im missing?
Upvotes: 0
Views: 754
Reputation: 1862
This is because you have two identical "user" keys in the returned object. Postman shows you the raw data returned, but when you call response.json()
it parses the data and converts it to a python dictionary, which cannot have two identical keys in an object (same for JSON by the way).
Upvotes: 0