It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add Label with REST API

Not sure what's going wrong, but when I try to add a label with the REST API, I end up getting a XSRF check failed error.

Maybe I'm not clear on what needs to be passed for adding a label to a page. Based on the API documentation, I figured something like this would work:

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

I'm not on their cloud. We host it ourselves.

You still need the header. XSRF check is there in server as well.

But why does it only impact the label? I've been able to make all sorts of other calls without this issue.

I am not sure about that!

Well, I added it and tested with the URL above, but it gives me a 400 error with the message "Could not parse Labels from ". Is the above how you set up labels for a post?

Check out:{id}/label-addLabels

Sample input:

        "prefix": "global",
        "name": "label1"
        "prefix": "global",
        "name": "label2"

I've seen that, as stated above, but it's not working. Even after adding the header, as you suggested, I receive the 400 error as per my previous comment.

Well, the header seeoms to have helped with the XSRF error. Now you are getting a bad input error. From what I see, you are not sending a json array. Can you try sending it with the proper fomat?And with the content type header et al?

You will find some examples here:

Yep, seen those examples. Done all of them with Postman. All of them worked (even without the header for the XSRF error, which only happened when trying to post a label (I could post pages without any error)). 

Putting in the header and my authentication in Postman, then using this format (as above): results in an error that it "Could not parse Labels from ".

I've managed to create pages, move pages, copy pages, delete pages, modify pages, but I can't add a label. is not valid from what I see. I am not in a position to test it now but the API is expecting a json array as far as I see from the doc. Similar to the create new page example.

Fair enough; that's what I was wondering. I'm getting a "No content with id" error. The ID matches the page ID.

Did you manage to get this working? I have a similar problem with the code below. 

curl -u user:pass -X POST -H "Content-Type: application/json" -d "[{"prefix": "global","name": "label"}]" "

Server returns "Could not parse Labels from"


try changing the -d "[{"prefix": "global","name": "label"}]" to 

-d  '{"prefix": "global","name": "label"}'

Yeah, I did get this working. I had to use: {"prefix":"global","name":"LABEL"}

does it change the case lik "label" instead of "LABEL" 

I am getting lowercase label 

Labels are converted to lower-case. In the example I provided, I just put label in caps since it should be replaced with your label. I should have put it as <your_label_here> or something like that.

is there a way to keep labels as they are, i.e.  not changing case ?

No, there is not. Testing in Confluence 6.4.2, putting in a label on the page with capital letters or a mix, the label is changed to all lower-case.

Community showcase
Posted in Europe

Christian Reichert, Björn Döhler, re:solution: Video and Slides online

Not one, but two f***ing legends busting myths about passwords and user management. From left to right: Christian Reichert and Björn Döhler from re:solution going on a grand tour. Video here:  h...

13 views 0 1
View post

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you