...
After creating a course via web service, clients may need to update the E field, with a value associated to the external system. This update call is different than the title, detailed above. The title field is attached to the node entity, however the External course ID field is attached to the course entity, a separate collection of data. It is used for primarily for internal purposes, and is seldom changed manually. However, in this case of a course created externally via web service, there may be a need to associate the new course with an external system ID.
...
Info | ||||
---|---|---|---|---|
| ||||
It is not recommended to update any other fields found in the course endpoint, except external_id, as they are automatically programatically created/updated when editing a course via the UI. |
Code Block | ||||
---|---|---|---|---|
| ||||
<?php $curl = curl_init('http://your-domain.com/restws/session/token'); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "admin:webservicepw"); //Your credentials go here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); $token = curl_exec($curl); print "Received token: " . $token . "\n"; // Token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%" // Build a course // The fields and allowed values are available on the full documentation site. $course = array( 'external_id' => 'ethosce_ext_id_12345', ); $json = json_encode($course); $curl = curl_init('http://your-domain.com/course/408'); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "admin:webservicepw"); //Your credentials go here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); $response = curl_exec($curl); print $response; |
...