Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send POST request, always sending GET request. #4309

Closed
PratsBhatt opened this issue Apr 18, 2019 · 6 comments
Closed

Unable to send POST request, always sending GET request. #4309

PratsBhatt opened this issue Apr 18, 2019 · 6 comments

Comments

@PratsBhatt
Copy link

PratsBhatt commented Apr 18, 2019

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.

@JoelEinbinder
Copy link
Collaborator

Did this work for you with a previous version of puppeteer?

@aslushnikov
Copy link
Contributor

@PratsBhatt seems to be working for me - just added a test that does exactly this and passes all bots.
If you have a good repro, we'd be happy to look into this.

Speculatively closing for now.

@PratsBhatt
Copy link
Author

@JoelEinbinder Yes it didn't work for me with the previous version.

@aslushnikov, I would try to create a repo. But It doesn't work for me. I get always GET request, even when I print the request after the .continue method.

@aslushnikov
Copy link
Contributor

I would try to create a repo. But It doesn't work for me. I get always GET request, even when I print the request after the .continue method.

@PratsBhatt The request.method() doesn't get updated when you override the method with request.continue({method: 'POST'}) call. However, the server does receive a POST request.

@Charles-Goodwin
Copy link

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!

@nhhockeyplayer
Copy link

nhhockeyplayer commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants