Forum Discussion

UpakulB's avatar
UpakulB
Contributor
9 years ago

How to reply to a message via Community Api V2

Hi 

I need to post a reply on existing message using Community Api V2.

I am using below service - 

 

https://api.lithium.com/community/2.0/<tenant_id>/messages/<message_id>/

 

Headers -

client-id: <clientID>
Authorization:Bearer <valid Token>

 

Body -

{
"data": {
"type": "message",
"subject": "hello world",
"body": "this is a message post.",
"parent" : <message_id> 

}
}

 

Getting success as a response but its not showing in the Message trail.

Can you please suggest the valid parameters for the same.

 

 

 

 

8 Replies

  • UpakulB - subject* and board* parameter are required for posting a new message using API V2. However, you are missing the board* parameter, which is required as shown here https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=messages#action-create-attachments. 

    Let me know if this worked for you or if you still can't find the message, could you please post the response of your message. 

     

  • UpakulB's avatar
    UpakulB
    Contributor
    9 years ago

    TariqHussain, thanks for your message

     

    As suggested I added the board Id in the Body

    {
    "data": {
    "type": "message",
    "subject": "hello world",
    "body": "this is a message post.",
    "parent" : "105",
    "board": {
    "id" : "health_and_fitness_club"
    }}}

     

    Got below Response, but still replies are not showing

    {
    "status": "success",
    "message": "",
    "http_code": 200,
    "data": {
    "type": "message",
    "id": "105",
    "href": "/messages/105",
    "view_href": "http://community.infogain.com:80/t5/Health-and-fitness-club/Carrom-Tournament-Successful-completion/m-p/105#M2",
    "author": {
    "type": "user",
    "id": "1051",
    "href": "/users/1051",
    "view_href": "http://community.infogain.com:80/t5/user/viewprofilepage/user-id/1051",
    "login": "Mohit_I"
    },
    "subject": "hello world",
    "body": "this is a message post.",
    "teaser": "",
    "board": {
    "type": "board",
    "id": "health_and_fitness_club",
    "href": "/boards/health_and_fitness_club",
    "view_href": "http://community.infogain.com:80/t5/Health-and-fitness-club/bd-p/health_and_fitness_club"
    },
    "conversation": {
    "type": "conversation",
    "id": "105",
    "view_href": "http://community.infogain.com:80/t5/Health-and-fitness-club/Carrom-Tournament-Successful-completion/td-p/105",
    "style": "forum",
    "thread_style": "forum",
    "messages_count": 1,
    "solved": false,
    "last_post_time": "2017-07-13T04:13:34.547-07:00",
    "last_post_time_friendly": "2 weeks ago"
    },
    "topic": {
    "type": "message",
    "id": "105",
    "href": "/messages/105",
    "view_href": "http://community.infogain.com:80/t5/Health-and-fitness-club/Carrom-Tournament-Successful-completion/m-p/105#M2"
    },
    "post_time": "2017-07-13T04:13:34.547-07:00",
    "post_time_friendly": "2 weeks ago",
    "depth": 0,
    "read_only": false,
    "language": "EN",
    "can_accept_solution": false,
    "placeholder": false,
    "is_solution": false,
    "solution_data": {},
    "metrics": {
    "type": "message_metrics",
    "views": 23
    },
    "current_revision": {
    "type": "revision",
    "last_edit_author": {
    "type": "user",
    "id": "1051",
    "href": "/users/1051",
    "view_href": "http://community.infogain.com:80/t5/user/viewprofilepage/user-id/1051",
    "login": "Mohit_I"
    },
    "last_edit_time": "2017-07-13T04:13:34.547-07:00"
    },
    "kudos": {
    "query": "SELECT * FROM kudos WHERE message.id = '105'"
    },
    "tags": {
    "query": "SELECT * FROM tags WHERE messages.id = '105'"
    },
    "labels": {
    "query": "SELECT * FROM labels WHERE messages.id = '105'"
    },
    "images": {
    "query": "SELECT * FROM images WHERE messages.id = '105'"
    },
    "videos": {
    "query": "SELECT * FROM videos WHERE messages.id = '105'"
    },
    "attachments": {
    "query": "SELECT * FROM attachments WHERE message.id = '105'"
    },
    "replies": {
    "query": "SELECT * FROM messages WHERE parent.id = '105'"
    },
    "ratings": {
    "query": "SELECT * FROM ratings WHERE message.id = '105'"
    },
    "custom_tags": {
    "query": "SELECT * FROM custom_tags WHERE messages.id = '105'"
    },
    "moderation_status": "approved",
    "user_context": {
    "type": "user_context",
    "kudo": false,
    "read": true,
    "can_reply": true,
    "can_kudo": true,
    "can_delete": true
    },
    "device_id": "google_chrome_59",
    "popularity": -342.51438194444444,
    "excluded_from_kudos_leaderboards": false
    },
    "metadata": {}
    }

  • UpakulB's avatar
    UpakulB
    Contributor
    9 years ago

    TariqHussain - This (id = 105) is the parent message and its visible but I need to post the reply and there is no reply added on this message yet.

  • UpakulB - Could you please use parent.id instead of a parent only. 

  • UpakulB's avatar
    UpakulB
    Contributor
    9 years ago

    When using parent.id getting below error-

     

    {
    "status": "error",
    "message": "Unable to parse the required Content-Body from the request.",
    "data": {
    "type": "error_data",
    "code": 308,
    "developer_message": "Unrecognized field \"parent.id\" (class lithium.api.lion.impl.StandardComplexObjectDefinition), not marked as ignorable",
    "more_info": ""
    },
    "metadata": {}
    }

  • UpakulB - For posting a reply using v2 parent param is being used. Could you please open a case with lithium support as your query seems to be right and you are getting the proper response.  

     

    I assume you have used all the required parameters mentioned in the doc

     

    POST /community/2.0/mytenantid/messages HTTP/1.1
    Host: api.lithium.com
    Content-Type: application/json
    Cache-Control: no-cache
    client-id: czY8mbW76Ac/Wz6+bAMhCm+sW5WSyhAO2odh28TB1/c=