Contentful logo

Contentful Community

Suddenly a lot of validation errors on CreateOrUpdateContentType API method

#1

Hello,

I’ve been working with the API for some weeks now and suddenly, since yesterday, a lot of validation errors show up for missing values on types that shouldn’t even have these values set.

For example for a field with type Symbol it’s giving a Validation Error saying that the value of linkType can’t be null and needs to be either ‘Asset’ or ‘Entry’.
But this doesn’t make any sense for a Symbol field.

  {
    "name": "in",
    "details": "Value must be one of expected values",
    "path": [
      "fields",
      0,
      "linkType"
    ],
    "value": null,
    "expected": [
      "Entry",
      "Asset"
    ]
  },

Update: I should say that I’m using the contentful.net package. I found that this serializes the content types with fields including a null value for fields that are not set. Like this:

"fields":[
    {
      "id":"name",
      "name":"Name",
      "type":"Symbol",
      "required":false,
      "localized":false,
      "linkType":null,
      "disabled":false,
      "omitted":false,
      "items":null,
      "validations":null
    }
    ]

If I remove the linkType and items lines from the json it does work.

Did something change in the API, so it doesn’t ignore null values anymore?
A solution could be to make sure the ContentfulManagementClient doesn’t serialize the fields that are not set. Using something like NullValueHandling = NullValueHandling.Ignore in the JSON serializer settings.

0 Likes