Forum Discussion

kjartan's avatar
kjartan
Contributor
10 years ago

Event subscription view_href

Hi,

 

Is there any way of getting restapi.response_style=view to work with event subscription? Everytime a new message is posted I receive a HTTP-POST XML call on my server but I cannot construct a URL of the message without doing a seperate external API-call (which I really don't want to do). I tried adding the parameter like this: /restapi/vc/events/subscriptions/events/name/MessageCreate/subscribe?restapi.response_style=view&event.callback_url=http://mywebsite.com/ without any success.... The XML I receive doesn't have the full nice view_href.

 

If this is not a possibility, is there any way I can construct the full forum message URL with only knowing the ID of the board, thread and message (without doing any API-call)?

 

Cheers,

Kjartan

6 Replies

  • kjartan - Yes, indeed you can, the Lithium redirection engine works based on the ID as long as you have the type mentioned with it. e.g.

     

    this thread over here, can be called with this URL as well and will redirect to the correct discussion

     

    http://community.lithium.com/t5/xyz/123/td-p/184105

     

    The red text needs to be same, which is the ID. In case of board, or category:

     

    http://community.lithium.com/t5/xyz/bd-p/studio

    http://community.lithium.com/t5/xyz/ct-p/Developer

     

    You see, if you hit above URLs, they will take you to correct destination, as long as the ID and the type mentioned is correct.

    Now you can construct a better looking URLs though, like http://community.lithium.com/t5/category/ct-p/Developer, http://community.lithium.com/t5/discussion/123/td-p/184105, http://community.lithium.com/t5/board/bd-p/studio

     

    Though you'll need to be slightly vary in case you have same board and category ID. I hope this helps.

  • joy_lim's avatar
    joy_lim
    Helper
    6 years ago

    Can you pls. add the view_href on the message event payload instead?

  • Imtiaz's avatar
    Imtiaz
    Ace
    6 years ago

    Hi Joy_lim, 

    An alternate solution is you can add view_href and some more fields if you want in the message payload by creating a new endpoint and give the callback URL as your new endpoint URL instead of your service while registering the message event subscription.

    /restapi/vc/events/subscriptions/events/name/MessageCreate/subscribe?restapi.response_style=view&event.callback_url=endpoint_url

    Next, in the lithium endpoint parse the message object and get the message id and make lithium message API call by passing that message id to fetch complete message data and pass to your service http://mywebsite.com/


    Example: Make message API call in the endpoint to fetch complete message data and pass to your service
    https://community.com/restapi/vc/messages/id/1?restapi.response_style=view

    Thanks,
    Imtiaz

  • joy_lim's avatar
    joy_lim
    Helper
    6 years ago

    Hi Imtiaz,

    Sounds like a workaround to me than a solution. Comparing these two approaches:

    1. Community adding a field, view_href, to the payload 

    vs. 

    1. Community Client creating an endpoint for the message event callback

    2. service (exposed by the endpoint) parsing the message id and making a Community API to retrieve message ID

    3. service making a callback to the client app passing the view href

     

    It sounds like it makes more sense to have it done on the Community side rather than having all clients of Community do those steps just to get that one attribute. 

     

  • Imtiaz's avatar
    Imtiaz
    Ace
    6 years ago

    joy_lim yes it's a workaround. If the requirement is urgent then you can use this workaround, and i have seen your idea regarding this case and gave kudos for it.