Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

rest API to get space Key by passing space name

Rahul Gupta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2017

please help me in getting rest API to get space key by passing space name.

1 answer

0 votes
Pavel Potcheptsov
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.
April 18, 2017
#!/bin/bash

SpaceName="$@"
Url="http://localhost:8090/rest/api/content"

SpaceKey=$(curl -s -n $Url/search?cql=space.title~%22$SpaceName%22\&limit=1 | python -mjson.tool | grep space)
SpaceKey=${SpaceId##*\/}
SpaceKey=${SpaceId%\"*}

echo "SpaceKey"

Run with

# ./scriptname.sh SpaceNameToSearch
Danilo Yasushi Saita April 2, 2019

This rest api does not seem to work.

Running it here, I get a random result from a different space.

Is that the expected behavior? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events