robfletcher/betamax — Issue #50: POST body not stored on tape when using HttpClient
Author: perlyking
Created: 2012-02-07 11:30:22+00:00
State: open

My code under test uses Apache HttpClient to post some JSON content:

```groovy
HttpPost httpPost = new HttpPost("http://foo.api")
httpPost.setHeader("Content-Type", "application/json")
HttpEntity reqEntity = new StringEntity(data, "UTF-8") // <- where data is a JSON string
reqEntity.setContentType("application/json")
httpPost.setEntity(reqEntity)
response = httpClient.execute(httpPost) // <- Betamax proxy-configured httpClient
```
I was expecting to see the JSON appear in the tape file in the `body` section, but it's empty. I have also tried annotating my Spock test method to no effect:

```groovy
import static betamax.MatchRule.*
@Betamax(match=[method, uri, body], tape="tape name")
```

I'm using Grails 1.3.7 and, in my buildConfig,

```groovy
dependencies {
test 'com.github.robfletcher:betamax:1.1-SNAPSHOT'
compile("org.codehaus.groovy.modules.http-builder:http-builder:0.5.1") {
excludes "groovy", "xml-apis"
}
}