Forum Discussion

LainieH's avatar
LainieH
Expert
10 years ago

Using API to add labels to ideas

I need to add predefined labels to about 300 ideas that we recently migrated from Jive.

 

Is there an easier way to add these labels (other than manually).

 

I'm new to REST API but eager to learn - is the above an example of a task that could be accomplished using this method?

 

thanks, 

 

Lainie

  • Hi LainieH

     

    you can use the message edit call to add labels to a message. See the labels.labels attribute in the linked documentation page.

     

    Hope it helps!

  • Hi LainieH

     

    adding a label is a "write" action so yes, you need to be authenticated for that. To learn all about the authentication model you can have a look at this page to begin with. Feel free to ask questions if any specific area is unclear.

     

    Kind Regards,

6 Replies

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi LainieH

     

    you can use the message edit call to add labels to a message. See the labels.labels attribute in the linked documentation page.

     

    Hope it helps!

  • LainieH's avatar
    LainieH
    Expert
    10 years ago

    Thank you again, very much.

    Is there a special way that I need to call the API since it requires authentication to get this data?

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi LainieH

     

    adding a label is a "write" action so yes, you need to be authenticated for that. To learn all about the authentication model you can have a look at this page to begin with. Feel free to ask questions if any specific area is unclear.

     

    Kind Regards,

  • tmarshall's avatar
    tmarshall
    Advisor
    9 years ago

    Hey PaoloT,

     

    Thanks for the information on this thread, but hope you can go into more detail on what people do to loop through to add a label.

     

    Task: Add a label to 500 - 1000 topics in the board. Board is called "Troubleshooting". Luckily the board was setup to "Use only predefined labels" and the label "Troubleshooting" is optional. How do I loop through all 500 message to add this label? Once I'm done adding the label would go back into the admin setting to make the label required on posts.

     

    I can use firefox httprequester and manually add a label to 1 of the topic after I find the ID using the example in the documentation.

     

    https://company.com/restapi/vc/messages/id/2683/edit?label.labels=Troubleshooting

    What do people use to programmatically loop through to get all the IDs and then add the same label to each topic in that board? Thanks for the advice on how to accomplish this task.

     

    Tim

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    9 years ago

    Hi tmarshall

     

    adding a thousand labels will likely require an automatic script of some sort (or either spending a very boring day sifting through the IDs and issuing the calls manually :smileyhappy: ).

     

    We do have other Rest calls you can use. For example, use LiQL to get all the message IDs :

    SELECT id FROM messages WHERE board.id = 'Troubleshooting' ORDER BY post_time ASC OFFSET 0 LIMIT 10

    This would give you the first 10 topics, ordered by post time ascending. You would need to paginate (by varying OFFSET and LIMIT) through the results to get all of them. 

     

    As you get the IDs , you can issue the call you already tried to set the label.

     

    Depending on whether this is an one off task, or something you might want to do again in the future, you will decide whether to write some script or create a proper tool (maybe using your favourite programming language). As always, Lithium Professional Services can also work with you on this task if it's too daunting!

     

    I hope it helps,

  • VikasB's avatar
    VikasB
    Boss
    9 years ago
    Hi Paolo
    Is there any way to add label with post when user log out.