Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Organizations and Map Layers - REST API Documentation #17
Last updated May 2019
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.
List of All Map Layers (Robot View)
List of All Map Layers (Human/ Web Browser View)
Viewing, creating, and updating organizations.
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