Forum Discussion

vidhyut_cisco's avatar
12 years ago

Email subscription on posts for a user via API call

We are trying to make a user subscribed to a particular post using REST API. 

Currently, we are using '/boards/id/<id>/messages/post' API to create a post and we are passing 'message.author' parameter to set an author. 
In the same way, we wanted to set the subscription using 'message.subscribe_type' parameter. 
What happens here is, since we are using one integration username and password for every user to create the post via endpoint, so the particular user is not getting ubscribed to the desired post or thread. 

We have also tried to make the user subscribed to a post using the '/messages/id/<id>/subscriptions/self/add' API, but it again needs the session key of that particular user to make it subscribed. 

Is there any other way using which we can make a particular user subscribed to a particular post or thread. 

3 Replies

  • YuriK's avatar
    YuriK
    Khoros Expert
    12 years ago

    Hey vidhyut_cisco,

     

    Through the API you can only subscribe yourself or make a global subscription.

     

    One possibility I can think of is to pass a session key to the endpoint and have the endpoint use the session key in rest calls.

     

    Otherwise, I think you will have to add the ability to subscribe as any user as an idea via rest to our Idea Board.

     

    Hope this helps,

     

    Yuri

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    To expand on what YuriK mentioned, if you're already authenticated to the REST API as a user with sufficient permission (i.e. an admin), it's actually pretty easy to get a session key for another user. See here:

    http://lithosphere.lithium.com/t5/rest-api/bd-p/developers-rest-api?leaf-id=AuthenticationManager.sessions.login#AuthenticationManager.sessions.login

     

    This is the relevant portion:

    "Log in as the specified user, and return a session key identifying the session created for the login. The authentication parameters can consist of... A login name only. This will succeed if the user associated with the call (via session key or cookies) has the permission "allow_switch_users" for the community."

     

    So once you have the session key for the desired user, you can make the subscription call as that user.

  • sachink's avatar
    sachink
    Adept
    12 years ago

    Hi Adam,

     

    Solution do work with Rest client. However when we try the same method from within endpoint it does not work. Can you please confirm.

     

    Thanks,
    Sachin