Forum Discussion
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
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".
Related Content
- 4 years agoInactive User
- 5 months ago