authorjapps / zerocode

A community-developed, free, opensource, automated testing framework for microservices APIs, Kafka(Data Streams) and Load testing. Zerocode Open Source enables you to create, change and maintain your automated test scenarios via simple JSON or YAML files. Visit documentation below:
https://zerocode-tdd.tddfy.com
Apache License 2.0
909 stars 399 forks source link

When body is blank and hitting POST request getting "Length Required" error 411 #670

Closed warademilind closed 4 months ago

warademilind commented 5 months ago

Below is log -

url:https://test.com/APIGateway/api/v1/TestSub
method:POST
**request:**
{
  "headers" : {
    "Authorization" : "Bearer dasd.dasd.dasdsd",
    "IPAdress" : "192.168.1.1",
    "BrowserSessionID" : "rerdfsd",
    "ServiceType" : "web",
    "Content-Type" : "application/json",
    "AuthToken" : "12333-FD7E-4834-AD3B-4234324"
  },
  "body" : { }
} 

**Response:**
{
  "status" : 411,
  "headers" : {
    "Date" : [ "Tue, 25 Jun 2024 16:45:10 GMT" ],
    "Server" : [ "Microsoft-HTTPAPI/2.0" ],
    "Content-Length" : [ "344" ],
    "Content-Type" : [ "text/html; charset=us-ascii" ],
    "Connection" : [ "close" ]
  },
  "rawBody" : "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\r\n<HTML><HEAD><TITLE>Length Required</TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=us-ascii\"></HEAD><p>HTTP Error 411. The request must be chunked or have a content length.</p>\r\n</BODY></HTML>\r\n"
}

In Postman, same request works properly. Please do needful help. I am using zerocode-tdd.version - 1.3.35 and 1.3.43

warademilind commented 5 months ago

@authorjapps , @santhoshTpixler can you help me here.

warademilind commented 5 months ago

I have also tried with removing body part as shown in example (https://github.com/authorjapps/zerocode/wiki#empty-http-body-payload) but same issue persists-

url:https://test.com/APIGateway/api/v1/TestSub
method:POST
request:
{
  "headers" : {
  "Authorization" : "Bearer dasd.dasd.dasdsd",
  "IPAdress" : "192.168.1.1",
  "BrowserSessionID" : "rerdfsd",
  "ServiceType" : "web",
  "Content-Type" : "application/json",
  "AuthToken" : "12333-FD7E-4834-AD3B-4234324"
 }
}
authorjapps commented 5 months ago

HTTP Error 411. The request must be chunked or have a content length.

The error what you get is a response from the server. Your server is complaining that:

HTTP Error 411. The request must be chunked or have a content length.

So it could be it is expecting an additional header actually. e.g.

"Content-Length" : "2048", 

Try the above and rerun, could potentially resolve this.

[!WARNING] 2048 or a different value? please check with your API provider for the correct value