Hi Guys, trying to build a pact test for an API th...
# pact-jvm
g
Hi Guys, trying to build a pact test for an API that returns a String (not a json), the consumer side pact method looks like this
Copy code
builder
    .given('the instruction is accepted')
    .uponReceiving('a request to create instruction')
    .path("$BASE_URL/instruction")
    .method('POST')
    .headers('Content-Type', 'application/json',
        'Accept', 'application/json')
    .body(buildPactDslJsonBody())
    .willRespondWith()
    .status(201)
    .body("1234")
    .headers(Map.of('Content-Type', 'application/json'))
    .toPact()

but when the pact is produced, it looks like this 

{
  "status": 201,
  "headers": {
    "Content-Type": "application/json"
  },
  "body": 1234
}

instead of string its converting the response body to a number, is the string response not supported by pact libs?
u
You are setting the content type to
application/json
, so the body will be a number. If it is just text, use
text/plain
g
@uglyog text/plain doesn't work either