Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I make a GET / POST API Request in Python?

+5 votes
asked Feb 13, 2021 by KKN (1,110 points)

Here is my code

import requests
r = requests.get('https://pokeapi.co/api/v2/pokemon/ditto')
print(r.status_code)

But It just returns this* :

[Errno -2] Name or Service not known

*Of course, it returns a CRAP TON more errors, but this is the most important one (I think).

If you actually know what you are doing, plz help...

Thanks in Advance,

~ KKN =]

1 Answer

+1 vote
answered Feb 13, 2021 by Jeff The Chicken (2,920 points)
selected Feb 13, 2021 by KKN
 
Best answer

Online gdb doesn't allow connection to the internet from programs. Try trinket.io.

commented Feb 13, 2021 by KKN (1,110 points)
reshown Feb 13, 2021 by KKN
Holy crap it worked...
Thanks ; ]
commented Feb 13, 2021 by Jeff The Chicken (2,920 points)
no problemo. BTW, PokeAPI looks cool, I didn't know something like that existed.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...