Hi there,
I’m creating confluence-cloud add-on.
It works, create dialog from web item, insert email text in dialog, send POST request to other site.
but when send POST request to other site, server shows below error and not work.
How can I fix these? I need your help. Thanks.
{ ctx: {} } Authentication verification error (401): Could not find authentication data on request
GET /add-new-customer?email=&companyName= 401 12.300 ms - 787
my atlassian-connect.json
...
"webItems": [
{
"location": "system.content.action/modify",
"weight": 200,
"context": "addon",
"target": {
"type": "dialogmodule",
"options": {
"key": "newCustomer"
}
},
"tooltip": {
"value": "Example tooltip"
},
"name": {
"value": "test"
},
"key": "web-item-example"
}
],
"dialogs": [
{
"key": "newCustomer",
"url": "/add-new-customer?spaceKey={space.key}",
"options": {
"chrome": false,
"height": "420px",
"width": "600px",
"header": {
"value": "Add a new customer"
}
}
}
]
new-customer.hbs
{{!< layout}}
<div>
<div class="aui-dialog2-content">
<form id="add-customer-dialog" class="aui top-label new-customer-dialog">
<div class="field-group top-label">
<label for="email">Email</label>
<input class="text long-field" type="text" id="email" name="email" placeholder="hogehoge@huga.com" />
</div>
<div class="field-group top-label">
<label for="companyName">Company Name</label>
<input class="text long-field" type="text" id="companyName" name="companyName" placeholder="Atlassian" />
</div>
<button id="dialog-submit-button" class="aui-button aui-button-primary">Submit</button>
<button id="dialog-close-button" class="aui-button aui-button-link">Close</button>
</form>
</div>
</div>
<script>
$(function(){
$("#dialog-submit-button").on("click", function(){
require('date-utils');
let now = new Date();
const request = require('request')
const options = {
uri: "https://test/api/customer_set",
headers: {
"Content-type": "application/json",
},
json: {
"mail_address": $("#email").val(),
"companyName": $("#companyName").val()
}
}
request.post(options, function(error, response, body) {
});
AP.dialog.close()
})
$("#dialog-close-button").on("click", function(){
AP.dialog.close()
})
})
</script>
logs. some info hidden
Why dialog call the same route?
GET /add-new-customer?spaceKey=SpaceKey&xdm_e=xdm_e&xdm_c=xdm_c&cp=cp&xdm_deprecated_addon_key_do_not_use=my-app&lic=none&cv=1.870.0&jwt=jwt 200 14.847 ms - -
GET /css/addon.css 304 0.894 ms - -
GET /js/addon.js 304 0.369 ms - -
GET /css/addon.css 304 0.448 ms - -
{ ctx: {} } Authentication verification error (401): Could not find authentication data on request
GET /add-new-customer?email=&companyName= 401 12.300 ms - 787