Cannot publish content from site to Contentful -- ValidationFailed

359 views Asked by At

Contentful newbie here. I'm having an issue with publishing content from our team website to Contentful using Contentful's API (C# backend).

Background: We have a content type called Post with a required field called Tags. Whenever I try to publish content from our testing website to our Contentful space, I get the following error:

enter image description here

Here's the data I've been trying to pass. As you can see, tags is not empty:

"{"entry":{
    "fields":{
        "title":{"en-US":"test post 4"},
        "description":{"en-US":"test comment 4"},
        "tags":{"en-US":["Lobsters; test data","United States of America","China"]},
        "author":{"en-US":"admin"},
        "authorId":{"en-US":6},
        "yearStart":{"en-US":"2003"},
        "yearEnd":{"en-US":"2015"}
        }
    }
}"

I can't replicate this issue in my local environment. Tried contacting Contentful Support as well and they are as clueless about the cause as I am.

Any idea what could be causing this error?

Thank you.

1

There are 1 answers

0
Stephan On

from the validation errors' detail field, it looks like you're using the /spaces/:spaceId/assets endpoint, not the /entries one, which is probably the one you want to use.

url is a special field for assets, which indicates where the actual file is located the Asset is referencing.

So make sure you're doing something like this:

curl \
-X PUT \
-H "Authorization: Bearer <accessToken>" \
-H "X-Contentful-Content-Type: post" \
-d '{"entry":{"fields":{"title":{"en-US":"test post 4"},"description":{"en-US":"test comment 4"},"tags":{"en-US":["Lobsters; test data","United States of America","China"]},"author":{"en-US":"admin"},"authorId":{"en-US":6},"yearStart":{"en-US":"2003"},"yearEnd":{"en-US":"2015"}}}}' \
https://api.contentful.com/spaces/<spaceId>/entries