I tried to get taxonomy vocabulary details with REST /entity/taxonomy_vocabulary/{id} end point

Here id is machine name for taxonomy vocabulary.

my rest.setting

 'entity:taxonomy_vocabulary':
    GET:
      supported_formats:
        - hal_json
        - json
      supported_auth:
        - basic_auth
        - cookie

I have give enough permission to administrator to access GET on taxonomy_vocabulary resource.

On Drupal 8 alpha 11 I got 500 Internal server error irrespective to Accept header ( i.e json or hal+json )
On Drupal 8 alpha 12 I got 200 ok with a fatal error Fatal error: Call to a member function access() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/dr8a12/core/modules/rest/src/Plugin/rest/resource/EntityResource.php on line 50 irrespective to Accept header ( i.e json or hal+json )

I have attached supporting snap for both.
While discussing this issue with Jeff Linwood (https://www.drupal.org/u/jefflinwood) we conclude that in Drupal 8 alpha 12 it is serialization error because of one or more entity field for vocabulary is not getting serialized properly.

Community review needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vivekvpandya’s picture

Issue summary: View changes
klausi’s picture

Taxonomy vocabularies are configuration entities, right? REST module in its current state only supports content entities, I guess we should document that somewhere.

Why do you need to retrieve taxonomy vocabularies?

larowlan’s picture

Status: Active » Postponed (maintainer needs more info)
vivekvpandya’s picture

I am working on GSoC 2014 project to create iOS client that manipulates nodes on drupal 8 site. in that while creating or updating content with a 'tag' field i want to give user choice for tags So I want to retrieve tags vocabulary on my iOS app.

More info on my project https://groups.drupal.org/node/407793#project15

larowlan’s picture

I think you will need to write a custom end-point (resource plugin), see the dblog example in core.

(Drupal\rest\Plugin\rest\resource\DBLogResource)

klausi’s picture

So you don't want to retrieve the vocabulary itself, but rather a list of terms in that vocabulary, right? First solution that comes to my mind is building a View with a REST export display that lists terms of that vocabulary.

clemens.tolboom’s picture

This is not a bug. The URI is changed as of Change notice https://www.drupal.org/node/2199185

You should use http://drupal.d8/taxonomy_vocabulary/tags

Easiest way is to install https://www.drupal.org/project/restui then enable all resources.

Check your rest tool for response codes. I got several different responses:

Using incorrect path: 404 (not found) | http://drupal.d8/entity/taxonomy_vocabulary/tags

Using correct path: 403 (access denied) | http://drupal.d8/taxonomy_vocabulary/tags

Setting more and more permissions : 500 | http://drupal.d8/taxonomy_vocabulary/tags

I did not managed to get a working Rest export so please tell us your result.

vivekvpandya’s picture

I have tested it with Drupal 8 alpha 12 and it is not canonical path /entity/taxonomy_vocabulary/{id} is correct path and result for them are displayed in attached screen shots.

vivekvpandya’s picture

Canonical endpoints are only available for node, user and I think comment entity types as per Drupal 8 alpha 12 experience.

clemens.tolboom’s picture

@vivekvpandya thanks for the correction.

I checked all methods for all resources using REST UI module with
jQuery('input[type=checkbox]').prop('checked', true);
then ran
select name, path from router where name like 'rest.%';
then checked for the non /entity endpoints
select distinct path from router where name like 'rest.%' and path not like '/entity%' ORDER BY path;
resulting in

/admin/config/user-interface/shortcut/link/{shortcut}
/block/{block_content}
/comment/{comment}
/dblog/{id}
/node/{node}
/rest/session/token
/taxonomy/term/{taxonomy_term}
/user/{user}
clemens.tolboom’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

Having configured for vocabulary using HAL GET

$ curl --user admin:admin --header "Accept: application/hal+json" --request GET http://drupal.d8/entity/taxonomy_vocabulary/tags

I get independent of permissions set on "Access GET on Taxonomy vocabulary resource"

PHP Fatal error:  Call to a member function access() on a non-object in /Users/clemens/Sites/drupal/d8/www/core/modules/rest/src/Plugin/rest/resource/EntityResource.php on line 50

Asking for non-existing id aka 'tagss' gives

$ curl --user admin:admin --header "Accept: application/hal+json" --request GET http://drupal.d8/entity/taxonomy_vocabulary/tagss

A fatal error occurred: The "taxonomy_vocabulary" parameter was not converted for the path "/entity/taxonomy_vocabulary/{taxonomy_vocabulary}" (route name: "rest.entity.taxonomy_vocabulary.GET.hal_json")

Guess this is a bug.

klausi’s picture

Category: Bug report » Support request

As said above: Taxonomy vocabularies are configuration entities. REST module in its current state only supports content entities, I guess we should document that somewhere.

clemens.tolboom’s picture

(doh) I read it , forgot it , then ... :-/

What I don't understand is why I can REST call it. Shouldn't rest module restrict to content entities only?

@vivekvpandya maybe ?:

[Stock response from Dreditor templates and macros.]

Please update the issue summary by applying the template from http://drupal.org/node/1155816.

clemens.tolboom’s picture

I've created #2300677: JSON:API POST/PATCH support for fully validatable config entities as that resolves @vivekvpandya GET

@klausi let's discuss why we shouldn't expose ConfigEntities in #2300677: JSON:API POST/PATCH support for fully validatable config entities

vivekvpandya’s picture

@clemens.tolboom sorry I am new to Drupal and I don't know that REST should not support ConfigEntity. I installed RESTUI custom module and it provides REST end point for that So I tried and get error.

clemens.tolboom’s picture

@vivekvpandya I use that module too. With that and https://github.com/build2be/drupal-rest-test I managed to POST node and comment ... I could use some help for other POST types. I've created Rest UI #2303369: Until #2300677 is fixed, show in REST UI that config entity resources are read-only

clemens.tolboom’s picture

@vivekvpandya I guess we can 'closed by design' this 'Support request' now we have #2300677: JSON:API POST/PATCH support for fully validatable config entities ?

As @klausi said its by design and I disagree through mentioned issue.

webchick’s picture

I think taxonomy is worth talking about in its own right, regardless of what we choose to do / not to do with config entities.

When you dump hal+json from an Article node, this is what you get:

No taxonomy for you!

As an implementor, who doesn't know (and shouldn't need to know) Drupal's underlying architecture representation of its data, it is utterly mystifying that uid, revision_uid, and image show up in the list of _links but not the "Tags" field. I would actually rate this a "major" "bug" from the perspective of someone trying to build e.g. a mobile application for Drupal.

If this doesn't belong here, and belongs in some other issue, happy to report it there instead. I think #2300677: JSON:API POST/PATCH support for fully validatable config entities is way too broad, though, and also has possibly security implications as mentioned there, so I doubt we'd want to do that wholesale (in core, at least). But for fields directly attached to content, people are going to expect those to be exposed in the JSON feeds from Drupal.

clemens.tolboom’s picture

@webchick let's please close this one and move over to the general issue.

Discussing only about taxonomy_vocabulary is not enough. If we expose ConfigEntities maybe we should reduce that list. I really would discuss over @ #2300677: JSON:API POST/PATCH support for fully validatable config entities

Regarding the HAL/Rest UX/DX it indeed is not what one expects. But there are some issues about it in rest.module component.

I myself found more issues which I haven't time to file :-/

clemens.tolboom’s picture

As the REST team decided #2300677-11: JSON:API POST/PATCH support for fully validatable config entities to put on hold this issue is postponed on it.

clemens.tolboom’s picture

Status: Postponed » Closed (duplicate)

I close this as #2300677: JSON:API POST/PATCH support for fully validatable config entities has a GET patch which is quite valid to have for several other resources. It's not really a dub but I see no better option.

clemens.tolboom’s picture

jacov’s picture

Version: 8.0.x-dev » 8.1.x-dev
Priority: Normal » Major
Status: Closed (duplicate) » Active
Issue tags: +Headless Drupal, +API-First Initiative, +DX (Developer Experience)

i am re-opening this issue and marking as major.

I agree with @webchick , taxonomy is it's own animal, and should not be bundled in with ConfigEntity #2300677: JSON:API POST/PATCH support for fully validatable config entities

as it currently stands, the taxonomy REST endpoints do not work.

Both produce a 403 Forbidden with error, see curl examples below.

this is a major show stopper for decoupled drupal 8 developers.

* /entity/taxonomy_vocabulary/{taxonomy_vocabulary} produces a 403 and {"error":""}

curl --request GET -k -s -i --user username:password --header 'X-CSRF-Token: YourTokenHash' 'https://example.com/entity/taxonomy_vocabulary/tags?_format=hal_json'
HTTP/1.1 403 Forbidden
...
...
{"error":""}

* /taxonomy/term/{taxonomy_term} produces a 403 Forbidden & null message

curl --request GET -k -s -i --user username:password --header 'X-CSRF-Token: YourTokenHash' 'https://example.com/taxonomy/term/1?_format=hal_json'
HTTP/1.1 403 Forbidden
...
...
{"message":""}

(...and yes, i checked permissions, and i have enabled both:
Access GET on Taxonomy term resource
Access GET on Taxonomy vocabulary resource
...)

jacov’s picture

Category: Support request » Bug report
jacov’s picture

Title: GET on entity/taxonomy_vocabulary/{id} is not working » REST endpoints for taxonomy not working. GET on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} not working
jacov’s picture

Title: REST endpoints for taxonomy not working. GET on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} not working » REST endpoints for taxonomy not working. GET on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} 403 Forbidden with Error
jacov’s picture

Title: REST endpoints for taxonomy not working. GET on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} 403 Forbidden with Error » REST endpoints for taxonomy not working. GET / POST on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} 403 Forbidden with Error
Wim Leers’s picture

Status: Active » Closed (duplicate)

Please do not reopen issues from almost 2 years ago. Please create a new issue.

jacov’s picture

Title: REST endpoints for taxonomy not working. GET / POST on entity/taxonomy_vocabulary/{id} & /taxonomy/term/{taxonomy_term} 403 Forbidden with Error » GET on entity/taxonomy_vocabulary/{id} is not working