InvalidAuthenticityToken from rails for POST request Hi All I have a rails server running to which I make a POST request.
The dataset is defined as
Now per rails documentation in order to make a POST a request I need to set the add "authenticity_token" to the query string. So if for example the authenticity_token is "xxxxxxx", the final url should look like http://mywebsite.com/doSomething?aut..._token=xxxxxxx
I get the authenticity token from the server in the flashvars.
I have a user defined canvas attribute called auth_token which I use to store the authenticity token.
Below is the openlaszlo code I use to make the request.
var d = canvas.datasets.ds; var content = get_my_content(); d.setQueryParam('lzpostbody',content); d.setQueryString({authenticity_token : encodeURIcomponent(canvas.auth_token) }); d.doRequest
In this code the setQueryString call seem to clear out the query params. If I change the order of the setQueryString and setQueryParam calls the opposite happe开发者_开发技巧ns.
The question is. Is there a way to set the query string without changeing/deleting the query params.
Thanks very much Puneet
I don't know anything about OpenLaszlo, but my guess is that setQueryParam
adds or modifies one param, whereas setQueryString
overwrites the whole query string with the contents of the object.
Shouldn't you want to just add the authenticity token?
d.setQueryParam('lzpostbody', content);
d.setQueryParam('authenticity_token', encodeURIcomponent(canvas.auth_token));
精彩评论