Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
REST API Documentation #17
Last updated July 2018
Here's a start to documentation for viewing, creating, and updating organizations.
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.
List of All Organizations (Human/ Web Browser View)
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.
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
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
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)
Example of Updating an Organization
Method: PATCH (Drupal purposely does not support PUT)
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
Example of Updating a Map
Helpful Tutorials (Tuts) and Documentation
JSON Validation Tool
Jim Summarizing the State of Drupal 8 PATCH