I am trying to use Content management API from PHP with Guzzle. I can easily get the list of records, but while creating new records I am getting issue. Code-
$headers = [ 'X-Api-Version' => '3', 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer '.$this->apiToken, ]; $params = [ 'data' => [ 'type' => 'marketad', 'attributes' => [ 'site' => 58096371, 'section' => 58096144, 'title' => 'Test from shop api', 'folder' => 58096601, 'sub_folder' => 58118224 ], 'meta' => [ 'created_at' => '', 'first_published_at' => '' ], 'relationships' => [ 'item_type' => [ 'data' => [ 'type' => 'item_type', 'id' => '1206971' ] ] ] ] ]; $datoCmsResponse = $this->client->request( 'POST', 'https://site-api.datocms.com/items', [ 'headers' => $headers, 'json' => $params, ] );
Array ( [data] => Array (  => Array ( [id] => 4d120e [type] => api_error [attributes] => Array ( [code] => INVALID_FORMAT [details] => Array ( [messages] => Array (  => #/data/type: failed schema #/definitions/item/links/3/schema/properties/data/properties/type: marketad does not match /^item$/. ) ) ) ) ) )
In the model-
- site, section, folder and sub_folder are single link referenced to another models
- title is single line string
Need some help here, because the error is not clear to me. Also is there any list of errors with details?