Hello! I have a problem regarding the <https://git...
# pact-ruby
l
Hello! I have a problem regarding the https://github.com/pact-foundation/pact-provider-verifier/ gem, as it seems that is sending a wrong formatted JSON body on the request. I am executing the next command: `bundle exec pact-provider-verifier hq-placements-client/pacts/hq-placements-client-hq-placements.json --provider hq-placements --provider-base-url ‘http://localhost:3000/’ The body in the contract is this one:
Copy code
"body": {
  "sort_field": "not permitted value"
}
And I can see that the provider is receiving this body:
Copy code
"{\"sort_field\":\"not permitted value\"}"=>nil
BUT in case I use the
query
instead of
body
in the contract json:
Copy code
"query": "sort_field=invalid"
The request works properly. Also, mention that I can do the same request using Postman or ‘curl’ and it works properly:
Copy code
curl --location --request GET 'localhost:3000/placements' \
--header 'Content-Type: application/json' \
--data '{
          "sort_field": "not permitted value"
}'
What am I doing wrong? Thanks a lot for anyone that could help me. 🙏
y
what version spec file are you using?
l
What do you mean by spec file? • I am using a contract with this specification:
Copy code
"pactSpecification": {
      "version": "2.0.0"
    }
• For the gem: pact-provider-verifier (1.36.1)
y
Hey hey, Yeah that is what I mean, just wanted to know if it was a v2 or v3+ spec (as that ruby verifier supports up to v2 only) just as a first pass for troubleshooting, may be worth raising that as an issue against the repo as well to track. Nothing reaches out to me straight away sorry!
l
Ah! ok, I will do so. I did some debugging and I can see that when the query method is a GET (catching-it with Wireshark), the body is translated into query params (what is formerly accepted, since body on a GET request is not the ‘correct’ way to handle the request). As fast as I change-it to other methods, the body appears and in a correct way.