Questions tagged [httpbuilder]

HTTPBuilder is a wrapper for Apache's HttpClient, with some (actually, a lot of) Groovy syntactical sugar thrown on top. The request/response model is also inspired by Prototype.js' Ajax.Request.

HTTPBuilder wraps Apache's HttpClient, with Groovy syntactical sugar thrown on top.

It handles common tasks such as building and parsing common content-types, handling common content-encodings, and built-in support for common authentication mechanisms. It works equally as well for simple REST-based requests, or ad-hoc web downloads.

The request/response model is inspired by Prototype.js's Ajax.Request.

206 questions
4
votes
2 answers

HTTPBuilder ignoring JVM proxy parameter

I need to go through a proxy to get to my target server. It seems that I can do it with code like this: def http = new HTTPBuilder( 'http://www.somesite.com') http.setProxy('proxy.com', 8080, 'http') but not like…
zoran119
  • 10,657
  • 12
  • 46
  • 88
4
votes
1 answer

How to use MockFor to mock client on HttpBuilder?

I have some Grails production code I'd like to test and I've seen some examples of that here, see below. Problem is that I run into MissimgMethodExceptions on the client part of the HttpBuilder. This is the production code I'd like to test: class…
SunSear
  • 230
  • 4
  • 9
4
votes
1 answer

Groovy HTTPBuilder Mocking the Client

This question is closely related to this question. The difference is that I'd like to follow the recommended approach of mocking the client. So, I have the following HTTPBuilder defined: protected readUrl() { def http = new…
Michael D Johnson
  • 889
  • 1
  • 10
  • 21
3
votes
3 answers

How to install and use httpbuilder plugin in grails

How to install and use httpbuilder plugin in Grails?
user903772
  • 1,554
  • 5
  • 32
  • 55
3
votes
2 answers

HTTPBuilder - How can I get the HTML content of a web page?

I need to extract the HTML of a web page I'm using HTTPuilder in groovy, making the following get: def http = new HTTPBuilder('http://www.google.com/search') http.request(Method.GET) { requestContentType = ContentType.HTML response.success = {…
3
votes
0 answers

Getting raw json string or customer jackson mapper from httpbuilder-ng get request

I'm updating groovy scripts from httpbuilder to httpbuilder-ng. These scripts interact with various webservices to get messages. I'm looking to parse the responses preferably using Jackson into objects. However, I can't seem to get the raw json…
alexnanrick
  • 31
  • 1
  • 3
3
votes
2 answers

java.lang.LinkageError Groovy 2.4.14 apache poi 3.17 jdk 1.8.0_92 http-builder 0.7.1

While trying to open Excel file from inputstream (Groovy 2.4.14 apache poi 3.17 jdk 1.8.0_92): def myWorkBook = new XSSFWorkbook(zis) I got error: Caught: java.lang.LinkageError: loader constraint violation in interface itable initialization: when…
3
votes
3 answers

Handling 'chunked' encoded response with HTTPBuilder/Groovy

I'm new to using groovy and have started to use it to test some REST services. I'm having an issue parsing my XML response from our service due to 'Content not allowed in prolog.' After awhile searching I came across a post saying there might be a…
Caleb S
  • 163
  • 11
3
votes
2 answers

Groovy install HTTPBuilder now that Codehaus shutdown?

I'm a groovy n00b and trying to use http-builder, but ALL of the examples on the web just reference the same @Grab statement which doesn't work. I assume it is because codehaus.org isn't hosting groovy stuff anymore. I've tried downloading the…
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
3
votes
1 answer

post params with groovy httpbuilder in mailgun

I am trying to invoke mailgun send message api. The following code works if I pass the params along with url - String targetUrl = "https://api.mailgun.net/v2/my_domain_name/messages?from=fromAddress&to=toAddress&subject=sub&text=random+message"…
saurabh
  • 2,389
  • 3
  • 22
  • 37
3
votes
4 answers

encoder function for multipart/form-data in groovy

I need to form a 'multipart/form-data' REST request with jpeg image and JSON file as the content.I am stuck with encoding the 'multipart/form-data' as a zip file. Can someone tell me, how I can achieve this with groovy RESTClient? I could not find…
3
votes
1 answer

Cannot install http-builder in grails

I have a strange behaviour in my grails 2.3.6 app. I'd like to use groovyx.net.http.HTTPBuilder but IDE reports that it's unable to resolve the class. So, I added the following line to my BuildConfig.groovy: build…
elkarel
  • 723
  • 2
  • 7
  • 20
3
votes
0 answers

PHP set protocol_version for stream_context_create

I want to access an oauth server with a php script, the remote server requires the following request: POST /oauth/token HTTP/1.1 Content-Type: application/x-www-form-urlencoded Content-Length: 81 Authorization: Basic CHAINE_ENCODEE…
Jules Marcilhacy
  • 161
  • 1
  • 11
3
votes
2 answers

HTTPBuilder set request contenttype

I am using the following code to execute a HTTP POST towards an external system. The problem is that the external system always gets a 'null' content type when using the code below. Is there a way to set the contenttype when using HTTPBuilder. I…
Marco
  • 15,101
  • 33
  • 107
  • 174
3
votes
1 answer

How can I download file with HTTPBuilder (HttpClient)?

I need to download and save file. I'm trying to use HTTPBuilder because it has simple API and supports cookies. I have written following code: //create new httpBuilder and set cookies def httpBuilder = ... def file = ... def inputStream =…
fedor.belov
  • 22,343
  • 26
  • 89
  • 134
1 2
3
13 14