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 didnt 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?
thank you and i wish you merry xmas and a happy new year.