cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2007
Views
5
Helpful
9
Replies

Unable to set Content-Length in the POST request using CVP Rest_Client

pk88
Spotlight
Spotlight

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"}}

 

pk88_0-1653407127987.png

 

 

Thanks

PK

2 Accepted Solutions

Accepted Solutions

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.

View solution in original post

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"

}

 

 

View solution in original post

9 Replies 9

Gerry O'Rourke
Spotlight
Spotlight

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

Hello Gerry,

Thanks for replying. I have verified the HTTPS web server, I don't see the Content-Length header being sent. 

pk88
Spotlight
Spotlight

Is there a way to see the complete request which is being sent from CVP app? Any help would be appreciated. Thanks.

You could log what you're sending, but the actual HTTP request would need to be captured via Wireshark.

 

david

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

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.

Glad to hear you solved the problem, can you tell me more about what you mean about a dummy body?

 

david

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"

}

 

 

Thanks for explaining the solution.

 

david