I am working on a Confluence plugin which uses a rest resource to upload a file to Confluence via a HTML Form in a vm file, which is loaded from within a servlet using TemplateRenderer.
because I am receiving “XSRF check failed” when I call my rest funtion (POST) after submitting the HTML form, I found via google that I should use #form_xsrfToken() macro within my HTML Form.
Unfortunately this doesnt get rendered, it appears in the text …
Post code responsible for showing the form at first place along with respective part of atlassian xml.
Is that an action that extends the ConfluenceActionSupport?
If macro appears as is, it means that is unknown/null, check spelling.
I dont thinkbyou can use the form macro from servlet unless you inject the xsrftokengenerator and generate token than you the validate. Switch servlet to action and hour problem will magically dissappear
The only way I got it working was to use a custom JS Form submit function which uses ajax to do the REST call and providing the appropriate header “X-Atlassian-Token: no-check”