Skip to content

Execute POST with form URL encoded params #86

@MiguelAngel82

Description

@MiguelAngel82

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions