I'm trying to migrate my content on Laravel to Contentful using its Management API for PHP.
Following the tutorials, I was able to get the error to show.
Validation error
However, the error it shows is very vague. How do I get it to show more detailed errors so I know what fields they occur on?
Here is the function where I put my logic:
public function posts()
{
$records = Post::take(1)->get();
$count = $records->count();
$environmentProxy = $this->contentful()['environmentProxy'];
$recordsMigrated = 0;
foreach($records as $record) {
$entry = new Entry(ContentfulHelper::$ID_BLOG_POSTS);
$title = $record->title;
$entry->setField(ContentfulHelper::$FIELD_TITLE, ContentfulHelper::$DEFAULT_LANGUAGE, $title);
$entry->setField(ContentfulHelper::$FIELD_SLUG, ContentfulHelper::$DEFAULT_LANGUAGE, AppHelper::instance()->generateSlug($title));
$entry->setField(ContentfulHelper::$FIELD_CONTENT, ContentfulHelper::$DEFAULT_LANGUAGE, 'Hello');
$entry->setField(ContentfulHelper::$FIELD_SUMMARY, ContentfulHelper::$DEFAULT_LANGUAGE, $record->summary);
$entry->setField(ContentfulHelper::$FIELD_META_TITLE, ContentfulHelper::$DEFAULT_LANGUAGE, $record->meta_title);
$entry->setField(ContentfulHelper::$FIELD_META_DESCRIPTION, ContentfulHelper::$DEFAULT_LANGUAGE, $record->meta_description);
$entry->setField(ContentfulHelper::$FIELD_FEATURED, ContentfulHelper::$DEFAULT_LANGUAGE, ($record->featured === 1));
try {
$environmentProxy->create($entry);
if ($record->status) {
$entry->publish();
}
$recordsMigrated++;
} catch(Exception $exception) {
echo $exception->getMessage() . "\n";
echo "Stopped at record: $record->id\n";
die();
}
}
return redirect(route('contentful.index'))
->with('message', "$recordsMigrated/$count Posts migrated successfully.");
}
Edit 1: The "Content" field is a rich text field. Is that the cause? Currently stored content is in Markdown
.