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
1
vote
1 answer

Finding XML element from RESTClient with XMLSlurper

I'm writing a Spock test, in which I have a REST web service that returns an XML like this: USER template111
Alex
  • 228
  • 1
  • 10
1
vote
1 answer

Avoid converting some values to JSON with groovy's HTTPBuilder/RESTClient

I'm trying to use groovy's RESTClient to add a design document to a CouchDB database. CouchDB requires the functions within the design document (e.g. map/reduce functions within views) to be strings rather than actual JSON Function objects.…
CarLuva
  • 550
  • 4
  • 14
1
vote
2 answers

Groovy httpbuilder post list params

I'm trying to consume a web service from my grails project. I'm using httpbuilder 0.7.2. Below is my http client. static def webServiceRequest(String baseUrl, String path, def data,method=Method.GET,contentType=ContentType.JSON){ def…
YoYo Honey Singh
  • 464
  • 1
  • 4
  • 21
1
vote
1 answer

Groovy httpbuilder ResponseParseException Invalid JSON string

i trying to build a api consumer in groovy using httpBuilder. My backend api returns json output with content type application/json. But when i set content type in httpbuilder object to JSON it throws Invalid Json String error. static def…
YoYo Honey Singh
  • 464
  • 1
  • 4
  • 21
1
vote
1 answer

Groovy - Jira OAuth integration using HttpBuilder

I want to get data using JIRA REST api with provided JIRA OAuth authentication service. Basically I'm able to achieve this task using ScribeJava with Groovy. But I want to decoupled all the process as below :- Request to get request token Request…
Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
1
vote
1 answer

Groovy HTTP Builder: Catching invalid formatted JSON response

Hi I'm using Groovy HTTPBuilder to make a POST call similar like this: http.request( POST, JSON ) { req -> body = [name:'testName', title:'testTitle'] response.success = { resp, json -> println resp.statusLine …
1
vote
1 answer

Groovy HttpBuilder json input trouble

I am having issues passing json parameters to a web action. I know that the web action works at the specified url http://projects.example.net/example/bugnetwebservice.asmx/MobileBuildAction, as I have tested it with postman with the json…
iHowell
  • 2,263
  • 1
  • 25
  • 49
1
vote
0 answers

How do I Mock a HTTPBuilder in Groovy?

My REST API will use HTTPBuilder to request a response from some URL. The response to the request will contain a body with XML or Json content. I already have this response, I want to mock the HTTPBuilder as: if {this URL} then return {that…
1
vote
1 answer

HTTP authentication in Groovy?

def http = new HTTPBuilder(url) http.auth.basic username, password def data = new URL(url) def response = data.getText() def relativePaths = new XmlParser().parseText(response) relativePaths.each {page -> def link =…
daniel.lozynski
  • 14,907
  • 6
  • 18
  • 21
1
vote
1 answer

Groovy/Grails - get HttpResponseException by using HTTPBuilder

I try to get a data of Grails application (MyApplication2) from another Grails application (MyApplication2). Boths application run locally. I get an exception thrown using the following code. Groovy try { def http = new…
Jils
  • 783
  • 5
  • 12
  • 32
1
vote
1 answer

Setting content type "application/pdf" in Groovy RESTClient / HTTPBuilder

I'm using Groovy's RESTClient/HTTPBuilder library to send GET and POST requests to a webservice. One resource requires a PDF with content type application/pdf. The response will be an XML. Request --> POST application/pdf Response <--…
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
1
vote
1 answer

Groovy HttpBuilder/RESTClient: how to input multiple form parameters of the same name

We have been using Spock to hit endpoints in api tests - up until now, we have been able to use a map to construct a POST body for json endpoints. But now we have an api with form params, with multiple parameters of the same name. Can't send in a…
orbfish
  • 7,381
  • 14
  • 58
  • 75
1
vote
2 answers

Grails httpbuilder json response

Having a few issues with the response handling of my httpbuilder post and json within my service I have: def jsonDataToPost = '{"accountNumber" : ' + accNo + ',"accountName" : ' + accName + '}' def http = new…
NewbieGrails
  • 93
  • 2
  • 11
1
vote
1 answer

NonProxyHosts usage with Groovy HttpBuilder

If I create my httpBuilder as shown below (assume that a proxyUsername IS set, so setCredentials is called), then calls to httpAddress-es that are passed in properly are routed through the proxy. However, the Application has some http calls that…
JoeG
  • 7,191
  • 10
  • 60
  • 105
1
vote
1 answer

Spock test - RESTClient: HttpResponseException: Not Found

I want to write a test for a GET request when the API returns 404. My test: def "Should return 404 - object deleted before"() { setup: def advertisementEndpoint = new RESTClient( 'http://localhost:8080/' ) when: …
Mateusz Ryndak
  • 87
  • 2
  • 6
  • 13