3/22/2021 7:55:15 PMIshmam
7 AnswersNew Answer
Ishmam Farhan solved!! I hope don't arrive too late! Try to add header "Content-Type" with value "application/json". Also it's good send "Accept" with same value. * Accept: tells to server you are expecting in response that mimetype * Content-Type: configure request that tell server that your contentbody is of that mimetype In you inspect the code of python lib you are using, you realize that when pass "json" parameter, it made the work for you. - https://docs.python-requests.org/en/master/api/#requests.Request - https://docs.python-requests.org/en/master/_modules/requests/models/#PreparedRequest.prepare_body Also, in API documentation there an advice mentioning it because accepts two ways of sending body: as json or encoded url https://pastee.github.io/docs/#submit-a-new-paste
Here do you have all info with some examples how to proceed with post requests https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch Easy... read and extrapolate to your python code
Ishmam Farhan let me a time to deep in how to code But at a glance I see 401 as response status. Reading paste.ee api docs https://pastee.github.io/docs/#errors 401 Unauthorized – Your Application/User application key is wrong.
David Ordás Looks like now I am the one who arrived late. 😅 Anyways, Thanks so much for the amazing answer!
you should complete the js course first, then you could look at how fetch works... in web context: it may be less restrictive to do that from server side, with nodejs for example...
David Ordás Hi! I have tried my best to follow this article and came up with the below code, but it is only returning a 400 Bad Request response: https://code.sololearn.com/WyC9y7wJAF9s/?ref=app There might also be some typo I left unnoticed. Anyways, let me know if you can make it work. (You can ping me in the ib to get a dev key)
David Ordás Yep, I got the the Developer key. Didn’t write in the code for privacy reasons. You can always get one if you want. (through ib)