Hi,
I have got a problem that I hope someone here could help me with. I am trying to add a label to a page using curl. Below is the code I use.
curl -u user:pass -X POST -H "Content-Type: application/json" -d "[{"prefix": "global","name": "label"}]" "https://my.confluenceserver.com/rest/api/content/2384495/label"
The authentication piece is working but it seems like the parameters I am using is invalid. The return error i am getting is.
{"statusCode":400,"data":{"authorized":false,"valid":true,"errors":[]},"message":"Could not parse Labels from [{prefix: global,name: label}]"}
I have been playing with the REST API browser as well but I get the same error there. I can successfully delete or list labels but the POST does not seem to work.
Any ideas?
Community moderators have prevented the ability to post new answers.
Managed to get this working. Had to use double double quotes
curl -u user:pass -X POST -H "Content-Type: application/json" -d "[{""prefix"": ""global"",""name"": ""hello""}]" "https://my.confluenceserver.com/rest/api/content/1234567/label"
Finally got this to work...in a nutshell ....and no NOOO double-quotes needed
Methods
1)
curl -u username:password -X POST -H "Content-Type: application/json" -d '[{"prefix": "global", "name": "abc"}]' "https://myconfluence/rest/api/content/9999999999/label"
The -d <data> needs to be a json compliant syntax format
You can just import json and get the exact string:
>>> import json
>>> data = [{'prefix':'global','name':'abc'}]
>>> json.dumps(data)
'[{"prefix": "global", "name": "abc"}]'
2)
You can also use the request to do this if you are using python
3)
Or you can follow the example to update a page adding in the "metadata":{"labels":[{"prefix": "global","name": "label1"}]}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.