Hi, all, I am using docker cli for verifying provi...
# pact-ruby
i
Hi, all, I am using docker cli for verifying provider, and getting such error:
Copy code
1) Verifying a some - with POST /graphql/ returns a response which has status code 200
     Failure/Error: expect(response_status).to eql expected_response_status

       expected: 200
            got: 500

       (compared using eql?)
     # /pact/bin/pact:15:in `<top (required)>'

  2) Verifying a some - with POST /graphql/ returns a response which has a matching body
     Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example

     Encoding::CompatibilityError:
       incompatible character encodings: ASCII-8BIT and UTF-8
     # /pact/bin/pact:15:in `<top (required)>'
From provider itself, I am getting something like:
Copy code
graphene_django.views.HttpError: POST body sent invalid JSON.
Could someone help?
I found the issue. In Ruby custom_middleware file I obtain id from curl query and then insert it to request body. I was need to remove all whitespaces:
Copy code
id = `curl -X POST <http://example.com|example.com> -H "Content-Type:application/json" --data-binary "@${PWD}/request_body.json" | jq .id -r`
# Replace string in request body
body_string = env['rack.input'].read
new_body_string = body_string.sub("placeholder", id.gsub(/\s/, ""))
new_body_io = StringIO.new(new_body_string)
env['rack.input'] = new_body_io
new_body = env['rack.input'].read
calling
id.gsub(/\s/, "")
resolves all issues
👍🏼 1