Retrieve Confluence Spaces as Picker Field in JSM

Eric January 11, 2024

Hi there,

Jira Service Management 5.11.3

i´m trying to provide a "customer request" on customers portal "Request access to Confluence space"

Therefore it would be handy to somehow list available Confluence Spaces, make them available as picker field (multi or single) in that request form.

I managed to find the REST endpoint of our Confluence DC instance

https:://%my-confluence-url%/rest/spacedirectory/1/search?type=global

Available apps:

  • Insights aka Assets
  • Automations
  • Extension for Jira Service Desk
  • Power Scripts
  • ProForma: Forms for Jira

Help would be appreciated.

Thank you

Eric

 

1 answer

1 vote
Hyrum Steffensen _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2024

Hello Eric!

I hope you are having a great day! My name is Hyrum, and I am a Power Scripts support engineer with Appfire. I came up with a solution and am posting an example script below. During testing, I tried out the /spacedirectory endpoint, but the data returned is in XML. Unfortunately, this is not supported by the SIL language. However, I was able to use the /space endpoint and it works great! See this Atlassian documentation for complete details on /space REST method:

https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#space-spaces

The SIL script below uses the httpGet() routine to get the JSON data from the /space endpoint in Confluence. Then, the names of all the Spaces are printed to "updateoptions.txt" so that it can be used by admUpdateCustomFieldOptions().

struct Results { 
string name;
number id;
string type;
string key;
}

struct ConfluenceSpacesData {
Results [] results;
}

HttpRequest request;
request.headers += httpCreateHeader("Content-Type", "application/json");
request.headers += httpBasicAuthHeader("admin", "admin");

ConfluenceSpacesData confluenceSpacesData = httpGet("http://localhost:8090/rest/api/space", request);

string spaces;
for (Results result in confluenceSpacesData.results) {
spaces += result.name + " (" + key + ")\n";
}

printInFile("updateoptions.txt", spaces);
admUpdateCustomFieldOptions("selectList", "updateoptions.txt", "", "", "", {"DEMO"}, {}, false, false, false);

Here is the documentation for admUpdateCustomFieldOptions().

It has been my experience that any script that uses REST or updates custom field options can be quite fiddly and not easy to use. For further assistance, please create a support request with us, and we will help you implement your use case to your exact specifications. Click on the link below:

Appfire Help Center

Regards,

Hyrum

Pablo Vergara (Appfire) January 12, 2024

Thanks for stepping up, @Hyrum Steffensen _Appfire_! - I see @Eric has created a support request (https://appfire.atlassian.net/browse/SUPPORT-164937).

We'll be happy to continue helping on this matter.

Best regards,

Pablo

Like # people like this
OMAR MOHAMED AHMED MOHAMED FATHY
Contributor
December 4, 2024

what is the name of the add on

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events