Open allella opened 9 years ago
http://tntfoss-vivekvpandya.rhcloud.com/node/40 https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8 http://build2be.com/content/state-rest-headless-drupal-8 https://www.drupal.org/node/2098511 http://www.slideshare.net/AcquiaInc/drupal-8-deep-dive-what-it-means-for-developers-now-that-rest-is-in-core https://www.drupal.org/documentation/modules/rest/start#configuration https://www.drupal.org/documentation/modules/rest/javascript http://lin-clark.com/d8-rest-slides/ - Nice external overview of the Drupal 8 REST mechanisms.
@Nunie123 I've added tag field filter to the above, example: tag_filter_id=1
@allella I've added tags as a filter to the events api. See my comment at Issue #12 .
SEE THE LATEST DOCUMENTATION AT
Organizations API Documentation Map Layers API Documentation
BELOW IS THE ORIGINAL, NOW OUT OF DATE, DOCS. See the Links Above
Here's a start to documentation for interacting with the Map Layers and Organizations APIs.
You'll want a tool that makes it easy to send HTTP requests to the rest API. For instance, Guzzle is a handy tool for PHP developers.
Some of the examples below are written for a test tool like Postman if you're running tests.
Need more background on REST testing / debugging tools?
Maps API
List of All Map Layers (Robot View)
URL To view all organizations - https://data.openupstate.org/rest/maps?_format=json
Method: GET Expected Response: 200 OK Authorization: None Required Headers - Drupal 8 REST does NOT support the Accept: header, so you MUST use the &_format= mentioned above. The reason for not supporting Accept: headers is documented.
Query String
List of All Map Layers (Human/ Web Browser View)
URL To view all map layers - https://data.openupstate.org/map-layers
Method: GET Expected Response: 200 OK Authorization: None Required
Organizations API
Viewing, creating, and updating organizations.
List of All Organizations (Human/ Web Browser View)
URL
Method: GET Expected Response: 200 OK Authorization: None Required
REST API List of All Organizations (Robot View)
If you get an Access Denied (error 403) on while you're already logged into Drupal as another user then try to open the URL in an Incognito tab.
URL
Method: GET Expected Response: 200 OK Authorization: None Required Headers - Drupal 8 REST does NOT support the Accept: header, so you MUST use the &_format= mentioned above. The reason for not supporting Accept: headers is documented.
Query String
Errors
If you get an HTML response that says "A client error happened" then you need to include/fix the _format= parameter.
Example of Viewing an Organization
URL: https://data.openupstate.org/node/7?_format=json OR the alias https://data.openupstate.org/organization/code-for-greenville?_format=json Expected Response: 200 OK Authorization: None Required
Set an accepted / desired content format
Headers - Drupal 8 REST does NOT support the Accept: header, so you MUST use the &_format= mentioned above. The reason for not supporting Accept: headers is documented.
Example of Creating a New Organization
Method: POST URL: https://data.openupstate.org/entity/node Authorization: Requires Basic Auth and a user / password hash Expected Response: 200 OK (serialized JSON of the full object) (no longer returns 201 Created) Headers to Send
Drupal POST Documentation
Notes: The _links->type->href value is required with hal+json, as it defines the entity. Do a GET on any organization node beforehand to verify/check the fields. Drupal will automatically set core fields like like created, updated, promoted, status, so it's really only necessary to set the title and custom fields (field_xyz) Predefined Field Values If a value is sent for one of the following fields, it must be one of the following or the POST will fail.
Example Body
Example of Updating an Organization
Method: PATCH (Drupal purposely does not support PUT) URL: https://data.openupstate.org/node/4 Expected Response: 200 OK (serialized JSON of the full object) Authorization: Requires Basic Auth and a user / password hash Headers to Send
Drupal Patch Documentation
Notes: The _links->type->href value is required with hal+json, as it defines the entity. It is possible to update many fields at once by including multiple values in the body. This example updates only one field, field_primary_contact_person.
Predefined Field Values If a value is sent for one of the following fields, it must be one of the following or the PATCH will fail.
Example Body
Example of Updating a Map