Hi All,
I'm trying to execute any call to confluence Rest Api from a java class. In the specific to create a space and then to create a page inside it.
the code to create a space is :
String spaceBody = "{ \"key\":\"RAID\", \"name\":\"Raider\",\n" +
"\"type\":\"global\", \"description\":{\"plain\": { \"value\": \"Raider Space for raiders\",\"representation\":\n" +
"\"plain\" }}}'";
String confluencePage = "https://<my-host>/wiki/confluence/rest/api/space/";
.......
URL url = new URL(confluencePage );
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Cookie", cookie);
DataOutputStream bodyPage=null;
bodyPage = new DataOutputStream(connection.getOutputStream());
bodyPage.writeBytes(spaceBody );
bodyPage.close();
I receive Ok 200 as response but I can't see any space in confluence created with that name or key.
Does someone if I need to execute any further step?
Many thanks
Hello Raffaele,
That fact you are getting a Ok 200 back should mean the space was created. With that said, the permissions on the newly created Space may not be set thus only allowing Administrators access to see it within the Space directory.
You can either check your space directory or run an API call to GET space to see if a result returns. Here is how to check the Space Directory:
Here is documentation for The Space Directory.
Along with the REST API calls for Spaces.
Please let us know if you do see the space within the space directory or the GET call. If it does display there you will need to set permissions to allow others to see the newly created space.
Regards,
Stephen Sifers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.