REST API v2: POST profile subprofiles
To add subprofiles to a profile an HTTP POST request can be sent to the following URL:
https://api.copernica.com/v2/profile/$id/subprofiles/$id?access_token=xxxx
The first $id
should be replaced with the ID of the profile you want to add a
subprofile to. The second $id
should be replaced with the collection ID or name.
The new subprofile data of the profile can be placed in the body of the message.
After a successful call the ID of the created request is returned.
Body data
You can create fields by specifying the properties and assigning it to the data body.
PHP example
The following PHP script demonstrates how the API method can be called.
// dependencies
require_once('copernica_rest_api.php');
// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 2);
// data to pass to the call, the new fields
$data = array(
'firstname' => 'John',
'lastname' => 'Doe',
'email' => 'johndoe@example.com'
);
// do the call
$api->post("profile/{$profileID}/subprofiles/{$collectionID}", $data);
// return id of created request if successful
The example above requires the CopernicaRestApi class.