Hi,
We are using confluence cloud instance,
we are trying to edit the existing confluence page using the page ID.I have attached the code below.
public static void main(String[] args) throws JSONException,
AuthenticationException, ClientHandlerException,
ClassNotFoundException, SQLException, ParseException, IOException {
String urlLink = "";
String auth = new String(Base64.encode(""));
String updatePage =
"{\n" +
"\"type\":\"page\",\n" +
"\"ancestors\":\n" +
" [\n" +
" {\n" +
" \"type\":\"page\",\n" +
" \"id\":1501003952\n" +
" }\n" +
" ],\n" +
"\"title\":\"Sprint Macro\",\n" +
"\"space\":\n" +
" {\n" +
" \"key\":\"LAS\"\n" +
" },\n" +
"\"body\":\n" +
" {\n" +
" \"storage\":\n" +
" {\n" +
" \"value\":\"<ac:structured-macro ac:name=\\\"attachments\\\">\n" +
" <ac:parameter ac:name=\\\"old\\\">false<\\/ac:parameter> <ac:parameter ac:name=\\\"patterns\\\">*<\\/ac:parameter> \n" +
" <ac:parameter ac:name=\\\"sortBy\\\">name<\\/ac:parameter> <ac:parameter ac:name=\\\"sortOrder\\\">ascending<\\/ac:parameter> \n" +
" <ac:parameter ac:name=\\\"labels\\\"><\\/ac:parameter> <ac:parameter ac:name=\\\"upload\\\">false<\\/ac:parameter> <\\/ac:structured-macro>\",\n" +
" \"representation\":\"storage\"\n" +
" }\n" +
" }\n" +
"}";
// rest/api/content/
// System.out.println(updatePage);
String Page = invokePostMethod(auth, urlLink ,updatePage);
}
private static String invokePostMethod(String auth, String url, String data)
throws AuthenticationException, ClientHandlerException {
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response = webResource
.header("Authorization", "Basic " + auth)
.type("application/json").accept("application/json")
.post(ClientResponse.class, data);
System.out.println("Client Responce " + response);
int statusCode = response.getStatus();
System.out.println("Status Code " + statusCode);
if (statusCode == 401) {
throw new AuthenticationException("Invalid Username or Password");
}
return response.getEntity(String.class);
}
}
Please correct me if i missed anywhere in the code.
Thanks
Naveen
Hi Colin,
You can try going to the user profile directly http://<confluenceurl>/users/viewuserprofile.action?username=replaceUsername this will trigger the indexer for this particular user and it might show up.
If that doesn't solve, please try reindexing Confluence from scratch, and this should fix your problem.
Best regards,
Felipe Alencastro
Rebuilding the indexes did the trick. Let's hope that this isn't a regular thing to do. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Colin,
The People Directory is generated by the table content which contenttype is USERINFO:
select * from content where contenttype like 'USERINFO';
You might want to check if the user is set there.
Also, check if the user is appeaing as deleted or disabled:
e.g.
Check here for more info.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bruna- the user does appear in the content table. Neither of the two queries shows the user. Any other ideas?
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.