Skip to content
Advertisement

can’t get the correct data by calling an API using python request library while it works with postman

After opening the enter link description here I can see an API gets called which returns some data in JSON format. Attached you may see as well.

enter image description here I am trying to call this API using my python script as follows.

JavaScript

but unfortunately, it returns me this message instead of the real data.

JavaScript

on the other hand, when I sent the same request using postman it returns me data. here is how I sent request using the postman.

enter image description here

my question is what changes do I need to bring in my python code so that the API calls correctly and returns me the data which I wish to receive.

Advertisement

Answer

Try using the json parameter instead of data:

JavaScript

Output:

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