Forum Discussion

nrajesh's avatar
nrajesh
Guide
8 years ago

Is there any way to add unique/hidden field to message from REST API

Hi,

Am posting messages in particular board from REST API. Messages might have same SUBJECT line (can post from Application / REST API), from these how can i identify which one is created from REST API. Is there any field to find it. Or can we set any customized field, if yes please tell me how to do it.

4 Replies

  • You could get a new field added to the message then write to it when creating via API, you could then use that custom field to power a custom component to display a flag or something when the field is true etc. 

     

    Support will be able to help with the custom field. 

  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    Hi nrajesh  Yes, lithium support can add an additional field to message API which can be used as a flag.  

    Or you can use another workaround to get it without adding any additional field.  I would say when posting the message through API, you can add a label/tag which can be used to identify the messages posted through rest API. 

     

    http://community.lithium.com/community-name/restapi/vc/blogs/id/[id] /messages/post

     

    tag.add (optional)string the tags to be added to the message, with each tag separated by a comma. For example: tag.add=tag1,tag2
    label.labels (optional)string The labels for the message, each label separated by a comma. For example: label.labels=label1,label2
  • nrajesh's avatar
    nrajesh
    Guide
    8 years ago

     

    Hi VikasB,

    I have created message with below given data, that also its throwing error,

     

    Method : POST

    URL : https://api.stage.lithium.com/community/2.0/hhhkhk/messages

    Headers: Content-Type - application/json
                    client-id - asdasdasdasd
                    Authorization - Bearer dfdsfsdfsd

    Data :
    {
                        "data": {
                                "type": "message",
                                "subject": "hello world",
                                "body": "this is a message post.",
                                "board": {
                                    "id": "abcdiscussions"
                                },

                               "labels":"test1, test2"
                            }
                    }

     

    Repsonse:

    {"status":"error","message":"Unable to parse the required Content-Body from the request.","data":{"type":"error_data","code":308,"developer_message":"'labels' object does not contain a 'list_item_type' property, which is required for lists.","more_info":""},"metadata":{}}

     

     

     

    Note: One more thing, which call can we use for REST API (https://api.stage.lithium.com/community/2.0/hhhkhk/messages OR http://community.lithium.com/community-name/restapi/vc)

    Regards

    Rajesh

  • VikasB's avatar
    VikasB
    Boss
    8 years ago

    nrajesh  You can use this one even with the GET call also

     

    https://lithiumstage.xyz.com/restapi/vc/blogs/id/[id]/messages/post?message.subject=Test&message.body=Test&label.labels=Test1,Test2'

    In your post call, I guess you are not sending the parameter in the required format as an error mentioned in your post.  The parameters should be like message.subject, messgae.body, label.labels etc. 

     

    Hope it would work for you.