apimulesoftraml

RAML, specify API request Content-Length value


I'm trying to set the value of the Content-Length property to 0 in my RAML file.
I first stumbled upon this thread : How to specify API request header value in RAML

When I tried implementing it with this code :

/update:
  post:
    description: Store updated data in database
    headers:
      Content-Length:
        enum: [0]
    body:
      ...

I got the response 400 Bad Request :

   {
  "code": "REQUEST_VALIDATION_ERROR",
  "message": "Required header Content-Length is missing."
  }

My IDE told me a string was expected but feeding with ["0"] didn't solve the problem. (I'm testing my API specification in Mulesoft Design Center.)

So is there something I did wrong or is there another way to set the Content-Length to 0 in the request's header ?


Solution

  • You should only try to define custom headers in RAML. A required header of the HTTP protocol like Content-Length must not be defined. It should be automatically generated to prevent errors.