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
111
votes
7 answers

Groovy built-in REST/HTTP client?

I heard that Groovy has a built-in REST/HTTP client. The only library I can find is HttpBuilder, is this it? Basically I'm looking for a way to do HTTP GETs from inside Groovy code without having to import any libraries (if at all possible). But…
smeeb
  • 27,777
  • 57
  • 250
  • 447
23
votes
2 answers

Is there an easier way to tell HTTPBuilder to ignore an invalid cert?

Per the docs, you can go through a rather clunky process of export a cert from a browser manually and getting it recognized locally. Is there anything similar to curl's --insecure switch to make this practical?
Josh Diehl
  • 2,913
  • 2
  • 31
  • 43
22
votes
3 answers

using groovy http-builder in preemptive mode

When using groovy's http-builder with basic authentication the default behavior is to send an unauthenticated request first and resend the request with credentials after receiving a 401 in the first place. Apache's Httpclient offers preemptive…
Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97
17
votes
3 answers

How to import groovyx.net.http

I don't understand maven or grape, and I'm an idiot so give me the step by step if your answer is "go grap X-dependency manager and then rtfm and you're set." Where do i find and dump files to make this line work: import…
Mikey
  • 4,692
  • 10
  • 45
  • 73
13
votes
5 answers

Posting JSON data with Groovy's HTTPBuilder

I've found this doc on how to post JSON data using HttpBuilder. I'm new to this, but it is very straightforward example and easy to follow. Here is the code, assuming I had imported all required dependencies. def http = new HTTPBuilder(…
Chris Laconsay
  • 402
  • 1
  • 3
  • 17
13
votes
3 answers

Groovy HttpBuilder - Get Body Of Failed Response

I am trying to use the Groovy HTTPBuilder to write an integration test that will verify a correct error message is returned in the body along with an HTTP 409 status message. However, I can't figure out how to actually access the body of the HTTP…
Bill Prin
  • 2,498
  • 1
  • 20
  • 27
13
votes
2 answers

Why is HTTPBuilder basic auth not working?

The following code doesn't authenticate the user (no authentication failure happens, but the call fails due to lack of permissions): def remote = new HTTPBuilder("http://example.com") remote.auth.basic('username', 'password') remote.request(POST) {…
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
11
votes
2 answers

HTTPBuilder query parameters

I am trying to understand the Simplified GET of HTTP Builder. I succeeded with simple GET request similar to a REST GET request. def client = new HTTPBuilder('http://pokeapi.co') def resp = client.get(path: '/api/v1/pokemon/1') static void…
devanon
  • 161
  • 1
  • 1
  • 12
10
votes
1 answer

Groovy HTTPBuilder Mocking the Response

I am trying to figure out how to write my Test cases for a service I am going to write. The service will use HTTPBuilder to request a response from some URL. The HTTPBuilder request only needs to check the response for a success or failure. The…
C0deAttack
  • 24,419
  • 18
  • 73
  • 81
10
votes
1 answer

Installing HTTPBuilder for Groovy

Apologies for the newbie question, but how do you install HTTPBuilder for Groovy? I've added the http-builder-0.7.jar, http-builder-0.7-source.jar, and http-builder-0.7-javadoc.jar to GROOVY_HOME/lib. Is there anything else I need to do? The…
James.Wyst
  • 859
  • 3
  • 8
  • 13
10
votes
3 answers

How to get the raw response and URL from HttpResponseDecorator

The REST Client of HTTP Builder returns a HttpResponseDecorator. How can I get the raw response out of it (for logging purposes)? EDIT (some code might be handy): withRest(uri: domainName) { def response = post(path: 'wsPath', query:…
zoran119
  • 10,657
  • 12
  • 46
  • 88
9
votes
4 answers

Using Groovy's HTTPBuilder, how do you set timeouts

I'm trying to set a connection timeout with Groovy HTTPBuilder and for the life of me can't find a way. Using plain ol' URL it's easy: def client = new URL("https://search.yahoo.com/search?q=foobar") def result = client.getText( readTimeout: 1…
Steve s.
  • 301
  • 1
  • 4
  • 13
9
votes
3 answers

POST with HTTPBuilder -> NullPointerException?

I'm trying to make a simple HTTP POST request, and I have no idea why the following is failing. I tried following the examples here, and I don't see where I'm going wrong. Exception java.lang.NullPointerException at…
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
7
votes
2 answers

Groovy HTTPBuilder : Getting the entity content from a GZIPed Chunked response

I need to send a POST request to a web server and be able to read the response sent by said server. I tried using the HTTPBuilder lib with this code : def http = new HTTPBuilder('http://myServer/') http.setProxy("Proxy_IP", 8080, "http") postBody =…
serty2
  • 73
  • 1
  • 4
7
votes
2 answers

Grails:Groovy:SSLPeerUnverifiedException: peer not authenticated

I want to hit an xml request to a url while running the code in my local system it is working well i have created a war file and deployed the same in server,but while running in server getting an exception 'javax.net.ssl.SSLPeerUnverifiedException:…
1
2 3
13 14