Page tree
Skip to end of metadata
Go to start of metadata

UserKey are required to perform operations on behalf of a user, I couldn't find any documented api to retrieve userKey, but luckily the deprecated (but still available) prototype API allows to retrieve the userKey for a given user. The information returned is very verbose so I am filtering it down.

//find userKey for username
var username = "patrick";

result.promise = httpClient.get(
  '/rest/prototype/1/search/user.json?query=' + username
).then(function (body) {
    var result = JSON.parse(body).result.filter(function (user) {
      return user.username === username;
  	if(result.length !== 1) {
      throw new Error("user " + username  +" not found");
    } else {
      return result[0].userKey;
  • No labels
Write a comment…