Hi All, I am trying to verify a contract with PUT...
# pact-js
g
Hi All, I am trying to verify a contract with PUT methods, but for all the calls I am getting "Content length missing" error, then after adding content length it is failing with Content Length already present error. Did anyone came across this scenario? We used JS to generate the contracts. The header in the contract looks like below
"headers": {
"Authorization": "Some Token",
"Content-Type": "application/json",
"Content-Length": 0,
"X-Cat-API-Tracking-Id": "99aa372a-1234-66ea-bb37-0242ac131112",
"accept": "*/*"
}
Without Content Length
"headers": {
"Authorization": "Some Token",
"Content-Type": "application/json",
"X-Cat-API-Tracking-Id": "99aa372a-1232-66ea-bb37-0242ac131112",
"accept": "*/*"
},
Did anyone come across this before?
m
Can you please share the actual errors you’re getting?
Sending a context type of
application/json
with a content length of 0 doesn’t make a lot of sense to me. What’s the idea there?
Is the error in the verification? Is it coming from your API or the Pact framework?
g
We are getting this error while doing pact verification @Matt (pactflow.io / pact-js / pact-go)
m
Thanks. What about the other questions ^^ ?
g
If we give content length, we are getting Content length already exists and when not given we are getting Content Length missing. This is happening for PUT calls
expected status of 204 but was 411
m
I’ll try to be clearer. I want to see the errors from Pact. Please set the log level to DEBUG and share that here (redacting any sensitive data)
g
Sure
@Matt (pactflow.io / pact-js / pact-go)
{ "providerName": "Service1", "providerApplicationVersion": "master_3994e4f762208aff874bf42dbef52385c7e55e04", "success": false, "verificationDate": "2024-04-09T120910+00:00", "testResults": [ { "interactionId": "8b06d6835762e857fb0b0d7e34c37fdb0d28f7f5", "mismatches": [ { "attribute": "status", "description": "expected status of 204 but was 411" } ], "success": false }, { "exceptions": [ { "exceptionClass": "org.apache.hc.client5.http.ClientProtocolException", "message": "Request to provider endpoint failed with an exception: Content-Length header already present" } ], "interactionId": "3fe246b40ef470e2da6c2f18e3080d1ea41a3ce0", "mismatches": [], "success": false } ], "verifiedBy": { "implementation": "Pact-JVM", "version": "4.5.2" }, "_links": { "self": { "title": "Verification result", "name": "Verification result 2059 for Pact between Consumer11 (1) and Service1", "href": "https://pact.com/pacts/provider/Service1/consumer/Consumer11/pact-version/11a810e49efd2efc608873fe9c52922203a4787e/verification-results/2059" }, "pb:pact-version": { "title": "Pact", "name": "Pact between Consumer11 (1) and Service1", "href": "https://pact.com/pacts/provider/Service1/consumer/Consumer11/pact-version/11a810e49efd2efc608873fe9c52922203a4787e/metadata/Y3ZuPTE" }, "pb:triggered-webhooks": { "title": "Webhooks triggered by the publication of this verification result", "href": "https://pact.com/pacts/provider/Service1/consumer/Consumer11/pact-version/11a810e49efd2efc608873fe9c52922203a4787e/verification-results/2059/triggered-webhooks" } } }
Here is the error
This is happening only for PUT Operations
Do you want the contract as well?
m
I want your verification logs when the test is failing, not the verification results from Pactflow. Also this looks like Java not JS.
g
Okay I will get you the logs. The contract was generated using JS. also can you share a sample contract for a PUT interactions?