Unsupported Content Type

Only Json data is accepted

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

Summary

The API will only accept JSON data in the body of a request. If data is being sent in a format other than JSON it will not be accepted.

curl -X POST --data "Non JSON data" -H "Authorization: ApiKey {ApiKey}" https://api.youmanage.co.uk/Companies

{
  "error": {
    "code": "YM1000",
    "reference": "https://developer.youmanage.co.uk/api/errors/ym1000",
    "target": "Validation",
    "message": "Validation failed",
    "details": [
      {
        "code": "YM0060",
        "reference": "https://developer.youmanage.co.uk/api/errors/ym0060",
        "target": "",
        "message": "Invalid content type. Only json data is accepted.",
        "details": null
      }
    ]
  }
}

   

Solution

Rewrite the request so that information is sent in the body of the request using the correct JSON format.

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