Forum Discussion
Hi Inactive User ,
You can look to use the subscriptions API over here to subscribe/unsubscribe a user to a label:
curl -X POST \
https://[COMMUNITY DOMAIN]/api/2.0/subscriptions \
-H 'content-type: application/json' \
-H 'li-api-session-key: [SESSION KEY]' \
-d '{
"data":{
"type":"subscription",
"target":{
"type":"label",
"id":"Mexico"
},
"board":{
"id":"vacationBlog"
}
}
}'
Please Give Kudos if you find this post useful and also mark this as Accepted Solution if this is the required solution.
Regards
Tarun Kumar
Thank you. Any thoughts on how I could create a link on a page with that script? I'm at a loss of where to use curl on a Community page. Component? Endpoint? Is it even valid in freemarker? Etc.
- MattV5 years agoKhoros Staff
ian You can build more complex LiQL calls with this object: https://developer.khoros.com/khoroscommunitydevdocs/reference/restbuilder
- Inactive User5 years ago
Would this be correct, then?
<#assign messagePostCall = restBuilder() .method("POST") .path("/subscriptions") .body({ "type": "message", "board": { "id": "board-test" }, "target": { "type":"label", "id": "Jupiter" } }) .admin(true) /> <#assign resp = messagePostCall.call() />
- Inactive User5 years ago
MattV and or Tarun I'm completely at a loss here. Can you show me specifically what to do?
I'm happy to either do this in an endpoint or with JQuery, but I'm just not sure how to get the subscription part to work with an API call.
I can get the basic call to work in JQuery using Tarun's script but beyond that I'm unable to understand what's required beyond this:
<@liaAddScript> ;(function ($) { $.ajax({ type: "Get", url: "/api/2.0/search?q=SELECT * FROM users WHERE id='${user.id}'", success: function (data) { console.log('SubscribetoLabel', data) }, }); })(LITHIUM.jQuery); </@liaAddScript>
I don't understand how to include the rest that Tarun included.
Related Content
- 11 months ago
- 2 years ago