Help with POST Form on Conflunce Addon

atlassian-connect-express

#1

Hi,

I am trying to do a post form for a add on i am building but dont get it to work.

i get a error when i press the submit button:

Authentication verification error: 401 Could not find authentication data on request
POST /macro 401 26.863 ms - 777
GET /atlassian-connect/all-debug.js 404 1.917 ms - 169

The GET route works.

Routes code:

 app.get('/macro', addon.authenticate(), function (req, res) {
             res.render('form',{});
         }
 );
 app.post('/macro', addon.authenticate() function (req, res) {
             res.send('<h1>Hi</h1>');
         }
 );

Form parameters:

<form class="aui" action="/macro" method="post">

Do anyone have a idea on what i do wrong?


#2

Hi!
Maybe need credentials?
Look here https://community.atlassian.com/t5/Jira-questions/Send-a-HTTP-POST-as-a-post-function/qaq-p/312384


#3

Hmm but that don´t look like Atlassian-conncect-express with node js? Is not that for Jira Server?


#4

Sorry, didn’t notice tag. Maybe that
app.post(’/macro’, addon.checkValidToken(), function


#5

Where does the error message come from? Your Node App or from the browser console?

I think it comes from Node, so the next thing to check is your addon.checkValidToken function. Can you show it to us?

If it is from the browser and therefore most likely an error coming from Jira, then i would try to send the Request over Atlassian Connect, so you could try

AP.request({
  type: "POST",
  url: "BASEURL/macro"
}, (err, data) => 
   // data == xml.responsebody i think :)
});

Notice you have to pass the absolute URL of your Node Backend because the Request will be send from Jiras Frame, therefore in *.atlassian.com space.


#6

Thank you for the response. i Both get the error in the node.js console and on the conflunce site where the macro is running. I dont know if there is a diffrence in this case but this is regarding Conflunce and not in Jira.

Do i need addon.checkValidToken when i use addon.authenticate()?