To add a new Core, a JSON data object has to be pushed via POST request to the API. If a Core with the same core name is already existing for the provided core user the request fails and an error is returned.

Request

The URL for adding a new core is without any core identifier:

/api/2.2/[user]/[apiHash_User]/cores

Using this URL, a core is added by sending a POST request with a JSON body:

{"apiHash": "testTest-1",
"coreSchema": "schemaName",
"coreName": "testCore",
}

Possible Fields

Each product provides the possibility to specify following fields (in JSON format):

fieldnametypedescription
coreNamestring, requiredname of the core. Has to be unique for the provided coreUser

apiHash

string, requiredA core specific apiHash with which the core specific requests are authorized later. The apiHash has to fulfill at least 3 of 4 requirements:
  • one lower case letter
  • one upper case letter
  • one number
  • one non-letter character (e.g. ?, !, -,...)
coreSchemastringname of the core schema that has to be used

Request Answer

The request answer corresponds to the operation state. Therefore, a http status of 201 (CREATED) means the successful creation of the Core. Otherwise, a detailed error message is provided.

PHP Client Implementation

The PHP Client API provides full functionality to store products in ContentOnTarget. The analysis of the product is applied automatically. 

<?php
include_once("ContentOnTarget-PHP-API-Client.php");
 
$config = com\repalogic\ContentOnTarget\Client\Configuration::getConfig("https://api.shopontarget.com/", "user", "userApiHash", "core name does not matter here", "core api hash does not matter here");

$coreApi = new com\repalogic\ContentOnTarget\Client\CoreApi($config);
$core = new com\repalogic\ContentOnTarget\Client\Core();
$core->setApiHash($coreApiHash);
$core->setCoreSchema($coreSchemaResult);
$core->setCoreName($coreName);
$coreResult = $coreApi->addCore($core);
?>