The response from a web service request will change depending on the type of request sent. Some responses contain an array of information, others only HTTP Status codes. The example return arrays shown have been decoded from JSON for readability.
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. The examples below show requests for user enrollment information, with responses where a user, uid 200, is enrolled in one course, nid 310, but not enrolled in another, nid 300.
Info | ||
---|---|---|
| ||
self: The current page being viewed first: The first page in the data set last: The last page in the data set. If this matches the value in first, the data set has been returned in full in the list option. list: The data set page range found in next: The next page in the data set, following the current page, self prev: The previous page in the data set, preceding the current page, self list: The data range of the current self request |
...
page |
Example Requests
A request to verify enrollment of user 200 in course 300, where the user is enrolled in the course. The call http://your-domain.com/course_enrollment.json?uid=200&nid=300 will return the following:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
stdClass Object ( [self] => http://your-domain.com/course_enrollment?uid=200&nid=310300 // The current page the list value displaying information [first] => http://your-domain.com/course_enrollment?uid=200&nid=310300&page=0 [last] => http://your-domain.com/course_enrollment?uid=200&nid=310300&page=0 [list] => Array ( [0] => stdClass Object ( [eid] => 185 [nid] => stdClass Object ( [uri] => http://your-domain.com/node/310 [id] => 310 [resource] => node [uuid] => 9aabcf09-58c3-4679-85b3-c5f7ddc93ac6 ) [uid] => stdClass Object ( [uri] => http://your-domain.com/user/200 [id] => 200 [resource] => user [uuid] => ba5bc8af-25d7-48de-bb54-87ae70ac33b5 ) [enrollmenttype] => [status] => 1 [created] => 1459800985 [timestamp] => 1459800985 [enroll_end] => 0 [code] => [user_type] => [data] => [feed_nid] => ) ) ) |
A request to verify enrollment of user 200 in course 400, where the user is not enrolled in the course. The call http://your-domain.com/course_enrollment.json?uid=200&nid=400 will return the following:
Code Block | ||||
---|---|---|---|---|
| ||||
stdClass Object ( [self] => http://your-domain.com/course_enrollment?uid=200&nid=300400 // The current page the list value displaying information [first] => http://your-domain.com/course_enrollment?uid=200&nid=300400&page=0 [last] => http://your-domain.com/course_enrollment?uid=200&nid=300&400&page=0 [list] => [] ) |
A request for all enrollments in the system, http://your-domain.com/course_enrollment.json will return the following:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
stdClass Object
(
[self] => http://your-domain.com/course_enrollment
[first] => http://your-domain.com/course_enrollment?page=0
[last] => http://your-domain.com/course_enrollment?page=3
[next] => http://your-domain.com/course_enrollment?page=1
[list] => Array
(
[0] => stdClass Object{ ... }
[1] => stdClass Object{ ... }
[2] => stdClass Object{ ... }
...
)
)
|
A request to review the second page of results from all enrollments in the system, http://your-domain.com/course_enrollment.json?page=1 will return the following:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
stdClass Object ( [self] => http://your-domain.com/course_enrollment?page=1 [first] => http://your-domain.com/course_enrollment?page=0 [last] => http://your-domain.com/course_enrollment?page=3 [prev] => http://your-domain.com/course_enrollment?page=0 [next] => http://your-domain.com/course_enrollment?page=2 [list] => Array ( [0] => stdClass Object{ ... } [1] => stdClass Object{ ... } [2] => stdClass Object{ ... } ... ) ) |
Create (POST)