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

Execute POST with form URL encoded params #86

Open
MiguelAngel82 opened this issue Aug 28, 2018 · 0 comments
Open

Execute POST with form URL encoded params #86

MiguelAngel82 opened this issue Aug 28, 2018 · 0 comments

Comments

@MiguelAngel82
Copy link

MiguelAngel82 commented Aug 28, 2018

Hi all,

I want to make a POST with URL encoded params and I have followed the guide, but it doesnt work. Executed it from cURL it works as expeted, but transforming it to HTTPBuilder doesn't work.

Code from cURL:

curl -X POST -u "user:pass" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials

Code made with HTTPBuilder:

    String url = 'https://bitbucket.org/'
    HTTPBuilder http = new HTTPBuilder(url)
    authSite.auth.basic 'user', 'pass'
    http.post( path: '/site/oauth2/access_token', body: [grant_type:'client_credentials'],
    	requestContentType: URLENC ) { resp ->
   			println "POST Success: ${resp.statusLine}"
  			assert resp.statusLine.statusCode == 201
    }

With the former code the response is "Bad request" while with cURL the response is as expected.

Is anything missed in the HTTPBuilder configuration?

Thanks in advance!

Regards,
Miguel.

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

1 participant