05-24-2022 08:49 AM - edited 05-24-2022 08:54 AM
Hello Folks,
I am using CVP Rest_Client call studio element to initiate a POST request. In the request it is mandatory to set the Content-Length as 0 (zero). I am trying to set this value in Headers part of the element, but for some reason i still get the below error. Any idea on how to set the content-length? Thanks in advance.
Rest_Client_01,custom,Response_Code,411
Rest_Client_01,custom,API_Response,{"fault":{"faultstring":"Content-Length is missing""detail":{"errorcode":"messaging.adaptors.http.flow.LengthRequired"}}
Thanks
PK
Solved! Go to Solution.
06-22-2022 09:28 PM
Hello David,
Thanks for the reply. I tried all the combinations in Postman, i used to get the exact same error when i wasn't setting the Content-Length as '0' as i wasn't sending anything in the body. Unfortunately we can't set content-length explicitly in the standard element for the post request. So i decided to insert a dummy body, with that i was able to workaround my problem.
06-24-2022 12:46 AM
If you look at the screenshot i have shared in my first post, the body content is empty. With that the API was expecting content-length=0 parameter. So i added below content in the body so that i can get rid of sending content length 0. With that my issue got resolved.
{
"Dummy":"Dummy"
}
05-24-2022 10:10 AM
PK,
I would check what the actually HTTP headers are been set as by using wirshark and sending the HTTP POST it a Web server using HTTP (and not HTTPS) - so you can SEE what the headers are set to.
(Its not going to work - sending it to a random HTTP server - but you will see the POST request).
My guess is that the Content-Length header is been set automatically by the REST client element itself and so setting it manually as a header might not work, i.e. not able to override a "default" header.
You might need to create a custom Rest element to do it?
(If you have access to the HTTPS web server - you are sending it to - you might also be able to see the raw request data)
Regards,
Gerry
05-24-2022 11:04 AM
Hello Gerry,
Thanks for replying. I have verified the HTTPS web server, I don't see the Content-Length header being sent.
06-03-2022 02:28 AM
Is there a way to see the complete request which is being sent from CVP app? Any help would be appreciated. Thanks.
06-03-2022 07:24 AM
You could log what you're sending, but the actual HTTP request would need to be captured via Wireshark.
david
06-20-2022 01:26 PM
After reading this more closely and in your screen shot you're setting a parameter which is what is included in the URL https://host/endpoin?parameter=2. But you talk about setting the header of content length, which I don't believe is possible even with a custom element. Actually I don't see why this needs to be zero as that seems to violate what that header means. The content length is the length of the request. I believe by default it's like 16 bytes. So I think you need to clarify with the API endpoint what they actually want.
david
06-22-2022 09:28 PM
Hello David,
Thanks for the reply. I tried all the combinations in Postman, i used to get the exact same error when i wasn't setting the Content-Length as '0' as i wasn't sending anything in the body. Unfortunately we can't set content-length explicitly in the standard element for the post request. So i decided to insert a dummy body, with that i was able to workaround my problem.
06-23-2022 03:44 AM
Glad to hear you solved the problem, can you tell me more about what you mean about a dummy body?
david
06-24-2022 12:46 AM
If you look at the screenshot i have shared in my first post, the body content is empty. With that the API was expecting content-length=0 parameter. So i added below content in the body so that i can get rid of sending content length 0. With that my issue got resolved.
{
"Dummy":"Dummy"
}
06-24-2022 04:54 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide