Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Inspecting Requests

Do you know about inspecting a request you just sent? If not, this lesson is right for you! To give you sense of how to do it, let’s have a look at how to get the URL of the request you sent:

Python
>>> response.request.url
Avatar image for Shafin Thiyam

Shafin Thiyam on June 20, 2021

urlpost='https://httpbin.org/post' request raise 405 error

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on June 21, 2021

@Shafin Thiyam The HTTP status code 405 means “method not allowed”. You’re most likely viewing the address in a web browser, which sends an HTTP GET request by default. You want to send your data with the POST method instead. To do that, you can use cURL in the command line, for example:

$ curl -i -X POST https://httpbin.org/post -H 'Content-Type: application/json' --data '{"key": 42}'
HTTP/2 200 
date: Mon, 21 Jun 2021 06:07:18 GMT
content-type: application/json
content-length: 416
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

{
  "args": {}, 
  "data": "{\"key\": 42}", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Content-Length": "11", 
    "Content-Type": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.58.0", 
    "X-Amzn-Trace-Id": "Root=1-60d02c96-7d669c2e4c0324306e437fe4"
  }, 
  "json": {
    "key": 42
  }, 
  "origin": "89.64.35.172", 
  "url": "https://httpbin.org/post"
}

Become a Member to join the conversation.