Hi all Im trying to create a pact between two serv...
# pact-jvm
b
Hi all Im trying to create a pact between two services where the request is content-type form-data. With some googling i've found this snippet:
Copy code
.withFileUpload("file",
                        "some.json",
                        "multipart/form-data",
                        new byte[]{10,40,61,153,16})
but what im struggling with is how to add non-file key:values pairs? a curl example would be:
Copy code
curl --location --request POST '<http://localhost:8888/v1/some/ep>' \
--form 'data1="abc"' \
--form 'data2="def' \ \
--form 'fileData=@"/some/file_dir/some_file.gz"'
Can anyone explain how i add
data1
and
data2
to my pact? Thanks a lot!
u
There was a PR that added support for adding other parts to the request. Let me try find it
b
👍 thankyou @uglyog
u
It contains an example test, which uses
addTextBody
to add other parts to the request
b
@uglyog sorry for delayed response, this was exactly what i need thanks for the help!
👍 2
@uglyog I've been having trouble playiing my test on the provider, it keeps failing with 422 error. I've noticed the pact body is stored in base64 on pactflow and in the pact JSON is there a reason for that and could that be causing the problem im seeing?
Sorry not sure on etiquette as to whether i should of tagged you here or not...seemed relevant to the original thread
Also, when i inspect the packet I only see about half of the body being sent via pact-verifier to my producer
u
It is binary data, so it can't be stored in a JSON file without being encoded
What are you using to verify the provider?
b
What are you using to verify the provider?
@uglyog Python's Pact Verifier cli tool
u
Ah! Yeah, that won't be able to handle binary payloads
b
🙂 do you know of tool that would? My services are not Java to Java so i cant use the maven plugin for the producer side
out of curiosity why wont it handle the binary payloads? is it just not implemented there?
u
It is using the Ruby version underneath, which only supports text based bodies. But you can try using the standalone verifier https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.9.8
b
@uglyog that standalone verifier has support for it correct?
u
Yes, it should support it
b
This worked! All seems good now 🙂
🎉 1