I currently working on JIRA cloud addon. I want to store my addon properties on JIRA cloud by using REST apis. I refered this tutorial https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/.
According to this for saving the properties, I used this REST call
Request :
PUT
/rest/atlassian-connect/1/addons/<addon_key>/properties/<property_key>
Response :
{
"status-code": 404,
"message": "Add-on with key does not exist."
}
Could you please give me a solution to fix this or is there any other way to store add-on properties on JIRA cloud.
Although the answer "Add-on with key does not exist." points to a wrong add-on key, in my case the problem was the context. As the app-properties-api documentation sais
Request issued by a user with insufficient credentials, e.g. for an app's data by anyone but the app itself, or for a app that does not exist.
Where the interesting part in my case was "for an app's data by anyone but the app itself" meaning that the requests have to be send within the app (a simple GET request from the browser will fail with the given error)
I had to send the request from within the app (index.js). First a PUT and then a GET for the property
app.get('/store', addon.authenticate(), function (req, res) {
var userKey = req.query['user_key'];
var clientKey = req.context.clientKey;
var options = {
headers: {
'X-Atlassian-Token': 'nocheck'
},
url: '/rest/atlassian-connect/1/addons/<add-on-key>/properties/<property-key>',
json: 'true'
};
getHTTPClient(clientKey, userKey).put(options,
function (err, response, contents) {
getHTTPClient(clientKey, userKey).get(
'/rest/atlassian-connect/1/addons/<add-on-key>/properties/<property-key>',
function (err, response, contents) {
contents = JSON.parse(contents);
res.render('test', {
'test': contents,
'status': response.statusCode
});
});
});
});
function getHTTPClient(clientKey, userKey) {
return addon.httpClient({
clientKey: clientKey,
userKey: userKey,
appKey: addon.key
});
}
This just a simple example and not meatn for production :)
I can confirm this analysis: such requests can only be done programmatically from within the application. Requests sent from a browser will not work.
This answer should be marked as solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Matthias Küspert: Are you sure this is not possible from the browser?
I don't know for the Properties API, but for Rest calls such as updating issues this is entirely possible with https://developer.atlassian.com/cloud/jira/platform/jsapi/request/
Example:
declare var AP;
export class JiraIssueFronendAPI {
public static async editIssue(issueKey: string, notifyUsers: boolean, updateDetails: IssueUpdateDetails): Promise<string> {
return new Promise<string>(async function(ok, nok) {
let url = `/rest/api/3/issue/${issueKey}?notifyUsers=${notifyUsers}`;
let options = {
type: "PUT",
contentType: "application/json",
data: JSON.stringify(updateDetails),
success: function(responseText: string){
ok(responseText);
},
error: function(xhr, statusText, errorThrown) {
nok(xhr + " " + statusText + " " + errorThrown);
}
};
AP.request(url, options);
});//promise
}//function
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It sounds like the add-on key is not correct. Check your atlassian-connect.json file again and make sure that it matches the key there exactly. Everything else seems to be correct.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checkd the key. It is correct. And again i check this call. I got success responce.
GET
/rest/atlassian-connect/1/addons/<addon_key>
In here i used basic auth and i authenticated as host user. Do i need to authenticated as addon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tharanga,
Were you able to fix this issue ?
I'm having the exact same issue.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any news on this?
I encountered the same problem. However, I authenticated with
AtlassianHostRestClients.authenticatedAsAddon()
from my plugin.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Update:
I did the call above via Firefox REST Plugin while logged in.
When doing the same thing programmatically in my plugin I see the following in my log:
PUT request for "https://kuespert-dev.atlassian.net/rest/atlassian-connect/1/addons/<plugin-key>/properties/testProperty" resulted in 201 (Created)
Created GET request for "https://kuespert-dev.atlassian.net/rest/atlassian-connect/1/addons/<plugin-key>/properties/testProperty"
GET request for "https://kuespert-dev.atlassian.net/rest/atlassian-connect/1/addons/<plugin-key>/properties/testProperty" resulted in 200 (OK)
But the values are all null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, didn't document the Firefox REST call:
URL:
Headers:
Content-Type: application/json
And being logged in in another browser tab in Jira/Cloud.
Result:
{
"status-code": 404,
"message": "Add-on with key does not exist."
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've got the sample problem... did anyone find an answer?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For me it's now working - I had a problem parsing the returned Json. But it's only working programmatically - not when called via the Firefox Rest client in the browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.