When trying to get the JSON output of the entityqueue containing two nodes, nodes are missing from it. Is it alright? How do I get JSON of entityqueue with nodes?


{  
   "data":{  
      "type":"entity_queue--entity_queue",
      "id":"3ecd6a7c-bb33-459e-8a37-51d5c44c6ea2",
      "attributes":{  
         "uuid":"3ecd6a7c-bb33-459e-8a37-51d5c44c6ea2",
         "langcode":"en",
         "status":true,
         "dependencies":[  
            "node"
         ],
         "id":"politics",
         "label":"Politics",
         "handler":"simple",
         "handler_configuration":[  

         ],
         "entity_settings":{  
            "target_type":"node",
            "handler":"default:node",
            "handler_settings":{  
               "target_bundles":{  
                  "article":"article"
               },
               "sort":{  
                  "field":"_none"
               },
               "auto_create":false,
               "auto_create_bundle":""
            }
         },
         "queue_settings":{  
            "min_size":0,
            "max_size":0,
            "act_as_queue":false
         }
      },
      "links":{  
         "self":"http:\/\/localhost\/~peterla\/drupal\/api\/entity_queue\/entity_queue\/3ecd6a7c-bb33-459e-8a37-51d5c44c6ea2?_format=api_json"
      }
   },
   "links":{  
      "self":"http:\/\/localhost\/~peterla\/drupal\/api\/entity_queue\/entity_queue\/3ecd6a7c-bb33-459e-8a37-51d5c44c6ea2?_format=api_json"
   }
}
CommentFileSizeAuthor
#9 2836404.patch822 bytesamateescu

Comments

petiar created an issue. See original summary.

amateescu’s picture

Category: Bug report » Support request
Status: Active » Fixed

That's because you are exporting the Queue, which is the config entity. You need to export the subqueue, that's the content entity which holds the items.

petiar’s picture

Status: Fixed » Active

Hey @amateescu, thanks for the reply. So how do I export the subqueue, what would be the URL? Currently I am using entity/entity_queue/politics?_format=json, where politicsis my queue.

amateescu’s picture

Status: Active » Fixed

If your queue is using the "simple subqueue" handler, then there's a subqueue with the same ID as the queue, so the URL would be entity/entity_subqueue/politics?_format=json I guess :)

petiar’s picture

Status: Fixed » Active

Unfortunately, I tried that URL you proposed, but it is returning empty object. I even tried to create a JSON configuration for this, but still nothing.

uuid: 0b9d51be-705d-4cc0-8fa6-40f7c46ec914
langcode: en
status: true
dependencies:
  module:
    - basic_auth
    - entityqueue
    - hal
    - serialization
    - user
id: entity.entity_queue
plugin_id: 'entity:entity_queue'
granularity: method
configuration:
  GET:
    supported_formats:
      0: hal_json
      2: json
      3: xml
    supported_auth:
      - basic_auth
      - cookie

Any idea what could be wrong? Items are there, I even checked in the entity_subqueue__items db table.

amateescu’s picture

The JSON configuration from #5 is still using entity:entity_queue instead of entity:entity_subqueue. Maybe that's the problem?

Are you using core's REST module to get the JSON representation of a subqueue?

petiar’s picture

Ah, sorry, copied the wrong code. I have this in the subqueue config:

id: entity.entity_subqueue
plugin_id: 'entity:entity_subqueue'

That should be ok, right? And yes, I am using the core'ß REST module. Drupal 8.2.2, cache cleared. Still empty result.

amateescu’s picture

I tried to use core's REST for the first time and it seems that the entity subqueue links definition is a bit wrong.

With this patch and using the REST UI module to enable the route for subqueues, I was able to properly see the JSON output at /entity/entity_subqueue/<subqueue_id>?_format=json.

amateescu’s picture

Status: Active » Needs review
StatusFileSize
new822 bytes

Oops, forgot to attach the patch :)

petiar’s picture

Hi @amateescu,

your patch works alright. I approve, thanks.

  • amateescu committed 7587e24 on 8.x-1.x
    Issue #2836404 by amateescu: Subqueues should not have a canonical link...
amateescu’s picture

Title: Nodes missing in JSON output. » Subqueues should not have a canonical link in order for them to be exportable through REST
Version: 8.x-1.0-alpha4 » 8.x-1.x-dev
Category: Support request » Bug report
Status: Needs review » Fixed

Cool, committed the patch to 8.x-1.x then. Thanks for testing!

josebc’s picture

Status: Fixed » Needs work

Latest dev breaks subqueue page when content translation enabled, entitysubqueue is defined as a content entity so content_translation_page_attachments will try to load the canonical path
function toUrl uses 'canonical' as a default

rajab natshah’s picture

Failed;

Capture description:

When we click "Edit items" we will get this error message
The website encountered an unexpected error. Please try again later.
and the tail for the error log will show:

[Thu Dec 22 10:06:51.990655 2016] [core:notice] [pid 1647] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 22 19:27:33.327738 2016] [:error] [pid 27472] [client 127.0.0.1:53560] Uncaught PHP Exception Drupal\\Core\\Entity\\Exception\\UndefinedLinkTemplateException: "No link template 'canonical' found for the 'entity_subqueue' entity type" at /var/www/html/test/drupal8/core/lib/Drupal/Core/Entity/Entity.php line 214, referer: http://localhost/test/drupal8/admin/structure/entityqueue

Environment:

Development, Staging, Production

Steps to reproduce:

@javascript @check @local @development @staging @production
Scenario: Check if we do have the Entityqueue, Language, Content Translation modules were installed in the system.
  Given I am a logged in user with the "webmaster" user
  When I go to "/admin/modules"
     And I wait
   Then I should see "Entityqueue"
     And the "Entityqueue" checkbox should be checked
     And the "Language" checkbox should be checked
     And the "Content Translation" checkbox should be checked


@javascript @init @local @development
Scenario: Add Entity Queue "Test Queue" and use "Test Content" content type.
  Given I am a logged in user with the "webmaster" user
  When I go to "/admin/structure/entityqueue"
     And I wait
   Then I should see "Add entity queue"
  When I click "Add entity queue"
     And I wait
   Then I should see "Add Entity Queue"
  When I fill in "Test Queue" for "Name"
     And I fill in "test_queue" for "Machine-readable name"
     And I check the box "Test Content"
     And I press "Save"
     And I wait
   Then I should see "The entity queue Test Queue has been added."


@javascript @init @local @development
Scenario: Add Test content N1, N2, N3, N4 nodes to the "Test Queue" entityqueue.
  Given I am a logged in user with the "webmaster" user
  When I go to "/admin/structure/entityqueue"
     And I wait
   Then I should see "Test Queue"
  When I click "Edit items" in the "Test Queue" row
     And I wait
   Then I should see "Edit subqueue Test Queue"

........

At this point we are getting the "The website encountered an unexpected error. Please try again later." in the site.
"No link template 'canonical' found for the 'entity_subqueue' entity type"

hitfactory’s picture

@RajabNatshah, that error is caused by this bug in core #2479377: content_translation_page_attachments() should check for a canonical link before generating a URL to it. The #8 patch on that thread will stop the error.

amateescu’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.