Forum Discussion

koushikniranjan's avatar
3 years ago

Idea Exchange Status and Comment Update via ReST API

We are looking for an option to programatically update Status of an Idea (In Idea Exchange page) and add a new comment to an idea by ReST API call. Is this possible? 

We have hundreds of Ideas that we collect and segregate them to different categories. We would want to do these updates at once instead of opening each page.  Any lead on this would help a lot.

Thank you.

  • Hi koushikniranjan  We recently did something similar and I found this thread very helpful. Solved: How do I change the status of an idea? - Atlas (khoros.com)

     

    To summarize the API calls I used:

    First to retrieve the list of ideas we were looking for ideas that were a certain age and had below a threshold of votes. You can customize this with your own constraints found here messages (khoros.com)

     

     

    api/2.0/search?q=SELECT id FROM messages WHERE depth=0 AND board.id ="[boardID here]" AND kudos.sum(weight) < [kudos here] AND post_time > [date1] AND post_time < [date2] AND status.key="[ideaStatus here]" LIMIT 1000

     

     

    Next I used the following call to change the status of an idea (Thanks to DougS for this one)

     

    restapi/vc/messages/id/[message id here]/message_status/set?message.status=/message_statuses/key/[status key here]

     

     

     

    When you change the status it will post a comment to the idea that says what the status was changed to . However, we wanted to add our own message explaining the reason for the change. So I used the following two calls to first get the newest comment on the idea (which should be the status change comment) and second to edit that comment with our message. (Thanks to PerBonomi whose idea this was)

     

    api/2.0/search?q=SELECT id FROM messages WHERE topic.id = '[id]' AND depth > 0 LIMIT 1
    restapi/vc/messages/id/[comment id]/edit?message.body='your message here'

     

     

  • Akenefick's avatar
    Akenefick
    3 years ago

    I tried updating a status and then editing the comment with an unverified account. It allowed me to update the status but prevented me from editing the comment. Is the account you are using unverified? You can set it to verified at the bottom of the user profile page.

     

5 Replies

  • Hi koushikniranjan  We recently did something similar and I found this thread very helpful. Solved: How do I change the status of an idea? - Atlas (khoros.com)

     

    To summarize the API calls I used:

    First to retrieve the list of ideas we were looking for ideas that were a certain age and had below a threshold of votes. You can customize this with your own constraints found here messages (khoros.com)

     

     

    api/2.0/search?q=SELECT id FROM messages WHERE depth=0 AND board.id ="[boardID here]" AND kudos.sum(weight) < [kudos here] AND post_time > [date1] AND post_time < [date2] AND status.key="[ideaStatus here]" LIMIT 1000

     

     

    Next I used the following call to change the status of an idea (Thanks to DougS for this one)

     

    restapi/vc/messages/id/[message id here]/message_status/set?message.status=/message_statuses/key/[status key here]

     

     

     

    When you change the status it will post a comment to the idea that says what the status was changed to . However, we wanted to add our own message explaining the reason for the change. So I used the following two calls to first get the newest comment on the idea (which should be the status change comment) and second to edit that comment with our message. (Thanks to PerBonomi whose idea this was)

     

    api/2.0/search?q=SELECT id FROM messages WHERE topic.id = '[id]' AND depth > 0 LIMIT 1
    restapi/vc/messages/id/[comment id]/edit?message.body='your message here'

     

     

  • koushikniranjan's avatar
    koushikniranjan
    Guide
    3 years ago

    Hi Akenefick ,

     

    Thank you so much for your reply. I couldn't check before as I was out of office. Let me try this and get back to you with my results. 

    Regards,

    Koushik N

  • koushikniranjan's avatar
    koushikniranjan
    Guide
    3 years ago

    Hi Akenefick ,

    The first solution of updating the status worked perfectly. But when I tried the 2nd part, I was able to get the latest message Id fine using the below GET API call

    {{API_PATH}}api/2.0/search/?q=SELECT id FROM messages WHERE topic.id = '126453' and depth > 0 LIMIT 1

    ID = 131358

    Then I tried to edit the comment on that Id using the POST call as below

    {{API_PATH}}/restapi/vc/messages/id/131358/edit?message.body='KoushikNiranjan_CustomMessage Via ReST API_Solution Accepted'

    When I did that, I got the below error as response. Any idea why would I be getting this error when I could do all the other GET and POST calls successfully?

     

    <response status="error">
    <error code="100">
    <message>
     
    message: Sorry, you must verify your email address using the verification link in the email you received when you registered. If you did not receive an email, or need us to resend it, please go to &lt;b&gt;My Settings &gt; Email&lt;/b&gt; and request a new email verification.
    </message>
    </error>
    </response>
     
    Thanks,
    Koushik N

     

  • Akenefick's avatar
    Akenefick
    Genius
    3 years ago

    I tried updating a status and then editing the comment with an unverified account. It allowed me to update the status but prevented me from editing the comment. Is the account you are using unverified? You can set it to verified at the bottom of the user profile page.

     

  • koushikniranjan's avatar
    koushikniranjan
    Guide
    3 years ago

    Thank you so much for this insight Akenefick . Was able to update the account and then the API call worked like charm! Thank you so much for testing this scenario and sharing your knowledge. Appreciate it.

     

     

    Thanks,

    Koushik N