0

I am using Drupal 8. I have installed the Rest module. I need to do polling so I also installed the Poll module. I created two questions with choices in poll and after that I created a view to show polls in that view with Rest Export enabled.

Now there are 3 fields I am showing in my REST export:

  • Question
  • Choice
  • PollID

currently I have two questions and their choices. Here is how its showing in JSON form.

     [{"question":"which is best city",
"choice_target_id":"Delhi, Mumbai, Chennai","id":"1"},
    {"question":"Where do you work?",
"choice_target_id":"Flat, Hotel, Factory, Shop","id":"2"}] 

But the thing is when I access the REST URL in my browser window where I am logged in it shows all the field as.

      [
{"question":"which is best city",
    "choice_target_id":"Delhi, Mumbai, Chennai","id":"1"},
    {"question":"Where do you work?",
    "choice_target_id":"Flat, Hotel, Factory, Shop","id":"2"}
] 

But when I am not login and when I then call the REST URL from Postman I get this:

[
    {
        "question": "which is best city",
        "choice_target_id": "",
        "id": "1"
    },
    {
        "question": "Where do you work?",
        "choice_target_id": "",
        "id": "2"
    }
]

choice_target_id is blank. What can be the reason of it?

4
  • Have you checked the permissions? In your views settings page please check the "Authentication" and "Access" values under "PATH SETTINGS" You can also check the permission of the Polls Module.
    – ktrev
    Jan 16, 2019 at 11:32
  • Authentication:No authentication is set Access:None
    – Mohd Maaz
    Jan 16, 2019 at 11:56
  • this is my setup in path settings
    – Mohd Maaz
    Jan 16, 2019 at 11:57
  • why there is problem only in choices if it the issue related to permissions
    – Mohd Maaz
    Jan 16, 2019 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.