0

In my application, I have my API that is in localhost:8000/api/v0.1/save_with_post.

I've also made a Python Script in order to do a Post Request on such Api.

### My script
import requests

url = 'localhost:8000/api/v0.1/save_with_post'
myobj = {'key': 'value'}

x = requests.post(url, data = myobj)

Is it possible to view headers and body of the request in Chrome rather than debugging my application code?

Vishal Singh
  • 6,014
  • 2
  • 17
  • 33
Tajinder Singh
  • 1,361
  • 2
  • 14
  • 26

3 Answers3

2

You want Postman.

With Postman you can either generate a request to your service from Postman itself, or set up Postman as a proxy so you can see the requests that your API client is generating and the responses from the server.

Willis Blackburn
  • 8,068
  • 19
  • 36
0

If you want to view the response headers from the post request, have you tried:

>>> x.headers

Or you could just add headers yourself to your POST request as so:

h = {"Content-Type": "application/xml", ("etc")}
x = requests.post(url, data = myobj, headers = h)
0

well, I don't know if there is a way you could view the request in Chrome DevTools directly (I don't think there is) however, I know there are two alternatives for seeing the request body and response:

1 - use selenium with a chrome webdriver
this will allow you to run chrome automated by python. then you can open a test page and run javascript in it to do your post request, see this for more info on how to do this:

you will need to use Selenium-requests library to use requests library with selenium

2 - use Wireshark
this program will allow you to see all the traffic that is going on your network card and therefore you will be able to monitor all the requests going back and forth. however, Wireshark will throw all the traffic that you network card send or receives it may be hard to see the specific request you want

White Death
  • 408
  • 5
  • 12