Forum Discussion
Hello Adam,
Thank you very much for these precisions ! I think I will indeed submit an Idea to make this "Me Too" a little bit more reusable.
In the meantime as you suggested, I think I will have to replicate the behaviour by hand, that is, redirect to the login page if the user is not connected (with a fallback_url), and make a rest call to add a Me Too if the user is already logged in.
That said, and juste to be sure, is the correct API call the one i suggested earlier, i.e. :
rest("/messages/id/MESSAGE_ID/ratings/key/question_metoo/ratings/add?rating.value=0.0")
?
Thanks again for your help :)
Hi VincentGabou and AdamA ,
Thanks for sharing your thoughts about this features and its limitations in its current state.
If Vincent try to replicate the behavior of a me too button he has to handle all the logic related to the authentication/registration status.
And as per my understanding there's also the management and the creation of a token which is needed to perfom an action in the platform.
Indeed at the end of every URL holded by a kudo or me too button there is ticket parameter (e.g &ticket=aMivVgLAcKnS_11676)
AdamADo you know if this token / parameter is mandatory ? If yes is there a way to generate it through an api call ?
Best,
Clement
- AdamA11 years agoKhoros Oracle
VincentGabou Yes, the rest call you referenced is the one you would use to give a me too. I believe a value of -1 is what we consider "not helpful" and a value of 1 is considered to be helpful.
Add (or change) the Me Too on a Question:
/messages/id/<message-id>/ratings/key/question_metoo/ratings/add?rating.value=1
Revoke the Me Too on a Question:
/messages/id/<message-id>/ratings/key/question_metoo/ratings/revoke
clemlith If this is used in the context of a custom component, as freemarker code, then the call will be made as the current user. If made via REST over HTTP then you would need to use one of our auth mechanisms to make the call as the current user. One of the mechanisms is to pass a sso.authentication_token along with the request (if you are using SSO). This token can be generated by using a REST call (see links below for more details). Please note that the sso.authentication_token is different that the token (aka ticket) used by the application that you saw in the out-of-the-box UI (ticket=aMivVgLAcKnS_11676). The token used by the out-of-the-box UI is not intended to be used for REST or for customizations. Also, the action links in the OOTB UI are not intended to be used when building customizations, the REST API should be used in those cases.
Auth for Non SSO:
http://community.lithium.com/t5/Single-Sign-On-SSO/Authenticating-via-REST-API-non-SSO/ta-p/61862
Auth for SSO:
https://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?page=authentication#sso
- VincentGabou11 years agoGuide
Thank you for all these information AdamA, everything is working almost perfectly fine, except for the last step, the actual "Add a me too".
I have successfully logged in in the name of the user, and have tested API calls through AJAX like fetching a given message (testing the read permissions), or editing an existing message (testing the writing permissions). Both of those calls worked well.
As for the AJAX Post call to "/messages/id/<message-id>/ratings/key/question_metoo/ratings/add?rating.value=1" after successfully logging in, however, I keep getting the "Autorisation refusée" (Authorization refused) with a 303 code from the API.
The code is pretty straightforward :
$.ajax({ type: "POST", url: "/restapi/vc/authentication/sessions/login", data: ({ "xslt":"json.xsl" }), success: function(loginResponse) { $.ajax({ type: "POST", url: "/restapi/vc/messages/id/" + questionId + "/ratings/key/question_metoo/ratings/add?rating.value=1, data: ({ "rating.value=1", "xslt":"json.xsl" }), success: function(meTooResponse) { console.log(meTooResponse.response); } }); } });
(We are using auto-cookie login, that's why we don't have to use the session_key after loging in).
As for permissions, I have authorized API Reading and Writing Permissions in the Admin of course (the two previous successful calls I made confirm that those settings are indeed active).
Do you know why I am getting this 303 error only for Adding a Me Too to a question ? Is there a setting I might have overlooked ?
Thanks in advance for any help you can provide !
EDIT : To add more info to my post, I have also tried to make the call via the FreeMarker Rest API, and the result is the same, i.e. "Authorization Refused".
- clemlith11 years agoExpert
VincentGabou: I'm getting the same error.
AdamA: Do you know why this error occurs please?
best,
Clement
Related Content
- 4 years agoInactive User
- 7 months ago