Hello,
I’m trying to create a new record with the Content Management API but I want to know if it is possible to post null to a required field.
I want to pre-fill some fields from the API call, and let the user finish the draft (upload a logo and pick a color).
I have created the following model where all fields are required. I want to fill the webshop_url, name, email and phone from the API and let the user fill in the colors and upload the logo.
But when i try to post the following attributes with my API call
"attributes": {
"phone": "0612345678",
"email": "test@test.nl",
"primary_color": null,
"secondary_color": null,
"logo": null,
"name": "Test shop",
"webshop_url": "https://test-shop.com"
},
I will get a 422 Unprocessable Entity with the following validation errors.
{
"id": "d8f388",
"type": "api_error",
"attributes": {
"code": "INVALID_FIELD",
"details": {
"field": "primary_color",
"field_label": "Primary color",
"field_type": "color",
"code": "VALIDATION_REQUIRED",
"options": {}
}
}
},
{
"id": "b27332",
"type": "api_error",
"attributes": {
"code": "INVALID_FIELD",
"details": {
"field": "logo",
"field_label": "Logo",
"field_type": "file",
"code": "VALIDATION_REQUIRED",
"options": {}
}
}
}
So my question is: Is it possible to post null to required fields and make a draft.