PollId in ForumThread Rest API

We are doing one use case POC and come across a blocker. Could anyone please help us in this. Below is the query.

We created a Thread in a Forum, which contains a Poll. 

When we fetch the Thread details using REST API: 

curl --location --request GET ' <domain-name>/api.ashx/v2/forums/10/threads.json' \
--header 'Rest-User-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

 

In the response, the hasPoll field is set to true. However, we are unable to fetch the pollId in the same response. 

 

Can you help us figure out how we can get the Id of the poll that was embedded in the Thread from the REST API response?

Parents Reply Children
  • You probably need to fetch the "raw" content.  You can't do that directly via REST API that I am aware of, but it is supported by the Widget and In-Plugin APIs.  So you would need to somehow create your own endpoint as a widget, an automation, or a plugin.

    I've had to do this from time to time and implemented it as a Widget that outputs JSON data, and then I use the REST API to execute the widget.  I've attached the widget I use, and an example REST call to execute it.

    To set this up...

    1. Download and import the Widget XML via Widget Studio.
    2. You can use the sample CURL call below, or create your own calling code.
    3. The Widget takes two params: `ForumId` and `ThreadId`
    4. The `Id` parameter won't change, this is the UUID of the Widget.

    Sample curl call to execute the widget.

    curl -H 'Rest-User-Token: YOUR-TOKEN-HERE' \
     'https://YOURSERVERNAME.com/api.ashx/v2/scripted?Id=7692cfee-1b7e-4805-8875-961f25776b64&ForumId=117&ThreadId=89'

    Example response with an embedded poll:

    {
        "Body": {
            "ForumId": 117,
            "ThreadId": 89,
            "Raw": "\u003cp\u003eHere is a poll.\u003c/p\u003e\n\u003cp\u003e[embed:33ecb077-39b7-4078-9b1e-dc3f977a690b:2240d149-84ba-4770-8c40-bc30e640eb3d:question=What%20is%20your%20favorite%20color%3F\u0026description=\u0026pollOptions=%5B%7B%22OptionId%22%3A%22289451e9-d1f9-4057-a3bd-c9501a24cb91%22%2C%22Option%22%3A%22red%22%2C%22Ordinal%22%3A0%7D%2C%7B%22OptionId%22%3A%2203b73601-4d2f-4421-9680-a1e5ab157d26%22%2C%22Option%22%3A%22green%22%2C%22Ordinal%22%3A1%7D%2C%7B%22OptionId%22%3A%2290cf2bf8-cc70-4c7d-bc00-dc3614996188%22%2C%22Option%22%3A%22blue%22%2C%22Ordinal%22%3A2%7D%5D\u0026ShowResultsConfiguration=1%2C1]\u003c/p\u003e"
        },
        "Info": [ ],
        "Warnings": [ ],
        "Errors": [ ]
    }

    /cfs-file/__key/communityserver-discussions-components-files/2858/_5F00_fetch_5F00_raw_5F00_thread_2D00_Widget.xml

  • Even within a a raw response, the poll itself is going to be fundamentally useless as it will have no UI or interaction options when rendered outside of community.  If the goal is to have external polls you can do this via REST using the poll APIs but it requires authenticating via OAuth and you still have to build a UI