I'm trying to create a page with labels:

java code:

URL obj = new URL(urlCnfl + "/rest/api/content/");
HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
conn.setRequestMethod("POST");
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes("UTF-8"));
conn.setRequestProperty ("Authorization", basicAuth);

def data='{'+
' "title": "title542764234534",'+
' "space": {'+
' "key": "SAUR"'+
'},'+
'"type": "page",'+
'"metadata": {'+
'"labels": ['+
'{'+
'"prefix": "global",'+
'"name": "label1"'+
'},'+
'{'+
' "prefix": "global",'+
' "name": "label2"'+
' }'+
' ]'+
' },'+
' "body": {'+
' "storage": {'+
' "value": "New page data",'+
' "representation": "storage"'+
' }'+
' }'+
'}';

OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(data);
out.close();

------------------------------

json data from your example to create a page. The page is created, all data is correct, except for labels, they are not. 

what's the matter? Thank you!

1 answer

0 vote
Thomas Schlegel Community Champion Apr 07, 2017

Hi Aleksey,

there's another community for developer's issues:
https://community.developer.atlassian.com/
Maybe you get an answer there sooner

BTW, I would not use my email-address as username. This is in invitation for spam...

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Confluence

Three common content challenges + how to manage them

An efficient enterprise content management system, or ECM, is a must-have for companies that create work online (cough   cough, all companies). If content calendars, marketing plans, and bu...

110 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you