question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to send POST request, always sending GET request.

See original GitHub issue

Steps to reproduce

await page.setRequestInterception(true);
 page.on('request', request => {
const overrides = {
        method: 'POST',
        postData: 'testurlid=5'
};
request.continue(overrides);
});
return page.goto(BASE_URL + '/testURL');

Tell us about your environment:

  • Puppeteer version: “puppeteer”: “^1.14.0-next.1555141000741”
  • Platform / OS version: Ubuntu 16.04
  • URLs (if applicable):
  • Node.js version: 10.15.3

What steps will reproduce the problem? Normally updating the GET request to POST doesn’t work. Please include code that reproduces the issue.

What is the expected result? Expected result is that Puppeteer does a post request successfully.

What happens instead? It sends a GET request.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Charles-Goodwincommented, May 8, 2019

I don’t think this issue should be closed I’m adopting screen scraping to collect data by trying to emulate a search request to various web sites This invariably means performing a post request using form data fields as my search criteria However Puppeteer doesn’t provide a conventional way of pragmatically sending POST requests As a workaround, you can utilise the request interruption which at best works 8/10 times when interrogating third party website that you have no control over. You are also rendered blind when debugging Puppeteer POST network traffic using Chrome devtools as POSTs are recognised as Request Method:GETs with the form data hidden - not nice! I’m currently entertaining two alternative workarounds: Simply navigate to the search page using puppeteer, automate populating the form fields and emulate clicking the search button Drawback - Causes a double hit to the third party website Or Build a scaled down version of the HTML search page on the fly using puppeteer with just the bear essential form data fields and emulate clicking the search button Drawback - What a faff - but at least the debugging should work fine!

0reactions
nhhockeyplayercommented, Jun 22, 2019

I am limited too hitting brick wall…

cannot penetrate API need to refab req body, do intercept graphQL is messy and click search button just isnt rendering off of JSON api’s

they need to produce some more real world formidable api examples requiring post or redesign the whole interface

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to send POST request to Node.js HTTP Webserver ...
I'll usually get the "POST ERR_CONNECTION_TIMED_OUT" error I mentioned earlier, but after a while, the server will (sometimes, not always) ...
Read more >
Unable to send POST request through Request API
I am trying to post a request to my own middleware at app installation. I am getting 405 error code in return.
Read more >
Add a Request Body to a POST Request | API Connector
If your POST request isn't working, a likely cause is a mismatched content type. Try adding in a content type into the header...
Read more >
GET vs POST - Difference and Comparison | Diffen
HTTP POST requests supply additional data from the client (browser) to the server in the message body. In contrast, GET requests include all...
Read more >
HTTP/1.1: Status Code Definitions
The server has fulfilled the request and the user agent SHOULD reset the document view which caused the request to be sent. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found