...
Table of Contents | ||||
---|---|---|---|---|
|
Read (GET)
Read, or GET, requests, return an array of information, including any records found to match the given criteria. The response array is structured to handle paginated requests, and includes a 'list' of the records on the current page.
...
Creation, or POST, requests, return an array of basic information about the new created entity. The HTTP status code returned will be 201 CREATED for successful requests.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
stdClass Object ( [uri] => http://your-domain.com/user/200 [id] => 200 [resource] => user [uuid] => 2fd044c5-ff4a-4bfe-8472-9b9b56eb0fc6 ) |
Info | ||
---|---|---|
| ||
See the a full creation request at Creating a user via web service |
...
Update, or PUT, requests, do not return any data, other than the a data array. HTTP headers are returned, which can be used to verify success. A status code of 200 OK, indicates a successful call.
...
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, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); $token = curl_exec($curl); // Token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%" // Only the fields being updated need to be sent $course = array( 'title' => 'My Title Update', ); $curl = curl_init('http://your-domain.com/node/25'); // Note the 25, which is the nid of the course we are updating curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($course)); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); $response = curl_exec($curl); print 'Updating...'; $json = curl_exec($curl); $cinfo = curl_getinfo($curl); $response = json_decode($json); if ($cinfo['http_code'] == 200 && empty($response)) { print 'The entity has been updated'; } |
Info | ||
---|---|---|
| ||
See an update request as part of Manipulation of course objects via web services |
Delete (DELETE)
Similar to UpdatesUpdate, Delete requests do not return any data, other than the a data array. HTTP headers are returned, which can be used to verify success. A status code of 200 OK, indicates a successful deletion call.
...