I am developing confluence blueprint where a user can choose between jira projects and use them for specific jira issues report.
Both instances are connected correctly with each other and I get results but only if I am logged as an admin. With normal user I am getting this:
<status>
<status-code>401</status-code>
<message>This resource requires WebSudo.</message>
</status>
Unfortunately I have to get the information from the jira server as AJAX post request with JavaScript and here is my code:
function pickDate(e, state) {
AJS.$('#spLebenStart').datePicker({
overrideBrowserDefault: true
});
getJiraUrl();
}
function getJiraUrl(){
var appUrl = AJS.contextPath() + "/rest/applinks/1.0/applicationlink/type/jira";
$.ajax({
type: 'GET',
url: appUrl,
data: {
key: "value"
},
dataType: "xml",
success: function (xml){
jiraID = $(xml).find("id").text();
},
complete: function(){
getJiraProjects(jiraID);
},
error: function() {
alert("ERROR @ getJiraUrl");
}
});
}
function getJiraProjects(applicationId){
var restUrl = AJS.contextPath() + "/rest/applinks/1.0/entities/"+applicationId+"?os_authType=any";
$.ajax({
type: 'GET',
url: restUrl,
data: {
key: "value"
},
dataType: "xml",
success: function (xml){
jiraProjectKeys = [];
$(xml).find("entity").each(function(){
jiraProjectKeys.push({id: $(this).attr("key"), text: $(this).attr("name")});
});
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
error: function() {
alert("ERROR @ getJiraProjects");
},
complete: function(){
AJS.$('#spSelect').auiSelect2({
placeholder: 'Projekt auswählen...',
data:jiraProjectKeys,
multiple: false
});
}
});
}
I have tried to use login information with basic authentication in AJAX but it didn't help. Of course I can hardcode the id in the code but what if it get changed? Its not the best solution imo. How can I manage the websudo problem?