It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
There is no built-in way to accomplish this. Since Atlassian publishes their own REST API as public, we could take advantage of that API to do this job for us. It would require scripting in whatever language someone at your company is familiar with. I can talk in pseudo code.
Our script could run a search to return some results –
https://confluence.domain.com/rest/api/search?cql=label=badlabel
This would return a list of results. I searched for badlabel
and I was returned two results, both are attachments. This list is paginated so we only could receive twenty-five pages at a time, at which point we'd have to pass the &start=25
parameter to indicate where to start the results. We might also want to limit results to &type=attachment
. I included an example of my results below.
Results are returned in an array, so we'd like to obtain each content's ID.
{ results:[ { content:{ id:"att37029975", type:"attachment", title:"image2015-10-15 9:55:5.png", _links:{ webui:"/display/~steve/Using+Transitions+to+set+Resolution?preview=%2F37029969%2F37029975%2Fimage2015-10-15+9%3A55%3A5.png", self:"https://confluence.domain.com/rest/api/content/att37029975" }, _expandable:{ container:"", metadata:"", extensions:"", operations:"", children:"", history:"/rest/api/content/att37029975/history", ancestors:"", body:"", version:"", descendants:"", space:"/rest/api/space/~steve" } }, title:"image2015-10-15 9:55:5.png", excerpt:"badlabel", url:"/display/~steve/Using+Transitions+to+set+Resolution?preview=%2F37029969%2F37029975%2Fimage2015-10-15+9%3A55%3A5.png", resultParentContainer:{ title:"Using Transitions to set Resolution", displayUrl:"/display/~steve/Using+Transitions+to+set+Resolution" }, resultGlobalContainer:{ title:"Steve Behnke", displayUrl:"/display/~steve" }, entityType:"content", iconCssClass:"icon-file-image", lastModified:"2015-10-15T09:55:05.000-07:00", friendlyLastModified:"Oct 15, 2015" }, { content:{ id:"att37029973", type:"attachment", title:"image2015-10-15 9:54:19.png", _links:{ webui:"/display/~steve/Using+Transitions+to+set+Resolution?preview=%2F37029969%2F37029973%2Fimage2015-10-15+9%3A54%3A19.png", self:"https://confluence.domain.com/rest/api/content/att37029973" }, _expandable:{ container:"", metadata:"", extensions:"", operations:"", children:"", history:"/rest/api/content/att37029973/history", ancestors:"", body:"", version:"", descendants:"", space:"/rest/api/space/~steve" } }, title:"image2015-10-15 9:54:19.png", excerpt:"badlabel", url:"/display/~steve/Using+Transitions+to+set+Resolution?preview=%2F37029969%2F37029973%2Fimage2015-10-15+9%3A54%3A19.png", resultParentContainer:{ title:"Using Transitions to set Resolution", displayUrl:"/display/~steve/Using+Transitions+to+set+Resolution" }, resultGlobalContainer:{ title:"Steve Behnke", displayUrl:"/display/~steve" }, entityType:"content", iconCssClass:"icon-file-image", lastModified:"2015-10-15T09:54:20.000-07:00", friendlyLastModified:"Oct 15, 2015" } ], start:0, limit:25, size:2, totalSize:2, cqlQuery:"label=badlabel", searchDuration:58, _links:{ base:"https://confluence.domain.com", context:"" } }
We will then loop through all attachment ID's we received. First we should add the new label. If we use a program like CURL we can indicate POST and pass the label –
curl -H "Content-Type: application/json" -X POST -d '{"prefix":"global","name":"goodLabel"}' https://confluence.domain.com/rest/api/content/att37029975/label
Then we should loop through all attachment ID's again and remove the old label –
https://confluence.domain.com/rest/api/content/att37029975l/label?badLabel
Apologies for my cryptic entry! I didn't realize I was interacting with the system in this way.
Yes, we've got Confluence 5.8, and I'm not a Sys Admin, just a user trying to help an internal customer who accidentally fat-fingered the wrong year for a label. It's on ~ 200 attachments, so I was hoping to find an end-user way to edit/replace her erroneous entry. After much digging, it seems there are several add-on possibilities, but I doubt my Sys Admins will install it just for this one client.
Any insights on how I can accomplish this for a single Space w/o involving the tech team?
Thanks mucho Steven! The client has decided to take 30 lashes and tackle the issue manually. I sincerely appreciate your thorough and useful reply! I'll forward the info to our Sys Admins, should this happen to another client in the future
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.