Empty Body

A request body is required for this action

Purple gradient wave Purple wave used to give a visual break between the header and body of the page.

Summary

The action that is being invoked requires additional information passed in the body of the request.

Some actions, such as creating an entity, will require additional information that is taken from the body of the request rather than the URL and failing to do so will result in this error being returned. 

curl -X POST --data "" -H "Content-Type:application/json" -H "Authorization: ApiKey {ApiKey}"  \
https://api.youmanage.co.uk/Companies
{
  "error": {
    "code": "YM0051",
    "reference": "https://developer.youmanage.co.uk/api/errors/ym0051",
    "target": null,
    "message": "A request body is required",
    "details": null
  }
}

   

Solution

You will need to ensure that you send the required information, which can be found in the API reference, as a valid JSON object in the body of the request.

curl -X POST --data "{ \"Name\": \"Awesome Inc.\" }" -H "Content-Type: application/json" \
  -H "Authorization: ApiKey {ApiKey}"  \
  https://api.youmanage.co.uk/Companies

{
  "id": 7,
  "name": "Awesome Inc.",
  "enabled": false
}