REST API - determine if a message is a comment or an answer (not a solution)
Hi,
I have a problem to determine if a message is a comment or an answer (not a solution)
For an application which uses the REST API I want to extract threads, find out the question, the solutions , answers an comments.
I am able to find the question and the solution(s) . What is missing ist the hierachy of answers and comment. I didn´t find any way to determine if one of the remaining messages in thread/messages/linear is an answer or an comment.
I Know I can ust the parent property, what I am doing already, but in my case I have a thread (Discussion), an answer (but not a solution) and a comment to the discussion topic. Both have the same parent. So what´s the way to determine if this is an answer or an comment ?
Maybe there is a better way the the data via REST API in that way I see it in our community.
The call I use is:
....restapi/vc/boards/id/THE_BOARD_ID/threads?restapi.format_detail=full_list_element&message_viewer.topic_sort_order=topic_start_date&message_viewer.message_sort_order=thread_ascending
I iterate over the XML Response , want to extract the data from every thread as I can see it our community
Thanks
Lutz
Hi Lutz,
I assume you're referring to the Q&A interaction style, in which case you’re correct, there is a distinction between answers and comments. As far as the REST API is concerned, however, they’re both replies to the root message. It’s actually the message metadata that distinguishes one type of reply from another.
You can use the “metadata/key” method on the “Message” object to determine the value of a metadata key for a particular message. The metadata key that determines whether a reply is a Q&A Answer is “qanda.answer”. So for example:
/restapi/vc/messages/id/5619/metadata/key/qanda.answer
If you receive a value of “true” then it is an answer. Otherwise, it's a comment.I hope this helps!
-Adam