Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON:API vs. core's REST Module #43

Closed
p-a-s-c-a-l opened this issue Nov 26, 2018 · 3 comments
Closed

JSON:API vs. core's REST Module #43

p-a-s-c-a-l opened this issue Nov 26, 2018 · 3 comments
Assignees
Labels
BB: Infrastructure Container Engine / Cloud Infrastructure Building Block BB: Report Generation Report Generation Building Block help wanted Extra attention is needed question Further information is requested

Comments

@p-a-s-c-a-l
Copy link
Member

According to this guide, it should be possible to access this node using Drupal 8's JSON:API via the following URI: https://csis.myclimateservice.eu/jsonapi/node/data-package/76

However, 404 Page not found is returned. Accessing the same node via the REST module does work: https://csis.myclimateservice.eu/node/76?_format=json

According to JSON:API vs. core's REST Module, the JSON:API should be the preferred method for accessing entities.

@fgeyer16 @patrickkaleta Could you please check why the JSON:API isn't working?
@therter Could you please make sure that the Map Component uses the JSON:API?

@fgeyer16
Copy link

The JSON:API is working properly. there is/was only a misinterpretation of the documentation it says:
http://example.com/jsonapi/node/article/{{article_uuid}}
The "76" in your example is only the node-id but not the UUID (which is 2f9ec849-f8c4-4eb8-870d-f7e6c9423274 for now).
I was not aware of this and needed myself now 1 1/2 hours to find this out. Even though it should have been clear for me at once if I had read the doc more precisely :-/.

To get a node by its nid you have to use the filtering capabilities of the json api:
/jsonapi/node/data_package?filter[nid][condition][path]=nid&filter[nid][condition][operator]=%3D&filter[nid][condition][value]=76
for nid 76

As a sort of explanation.
Since drupal stores the revisions of a node every revision gets an own uuid and the nid is pointing to the last revision of the node (as far as I understand it). By using the uuid the jsonapi is able to fetch revisions of the node and not only the current node content.

@p-a-s-c-a-l
Copy link
Member Author

OK, great. So the csis-helpers-module should be extended to retrieve also the uuid.

In the meantime we can use the filter capabilities but should be aware, that the awkward syntax may trigger some false positive security alerts:

grafik

@p-a-s-c-a-l
Copy link
Member Author

resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BB: Infrastructure Container Engine / Cloud Infrastructure Building Block BB: Report Generation Report Generation Building Block help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants