I need to update a confluence page by java. I find the documents in here https://docs.atlassian.com/atlassian-confluence/REST/latest/
But when I use them, it response with "HTTP/1.1 405 Method Not Allowed", following is my code
@Test public void testHttpPut() throws IOException { HttpClient client = new HttpClient(); UsernamePasswordCredentials cred = new UsernamePasswordCredentials(user, passwd); AuthScope auth = new AuthScope(AuthScope.ANY); client.getState().setCredentials(auth, cred); HttpMethod putMethod = new PutMethod("https://confluence.XXX.com/rest/prototype/latest/content/33064104?os_authType=basic"); putMethod.setDoAuthentication(true); client.executeMethod(putMethod); System.out.println(putMethod.getStatusLine()); System.out.println(putMethod.getResponseBodyAsString()); putMethod.releaseConnection(); }
But When I use GetMethod, it response with success, Why?
Community moderators have prevented the ability to post new answers.
Hi Tian,
Try using JSON RPCs, check out the link below: https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods#RemoteConfluenceMethods-Pages
In this page do a search for the method : updatePage , its under the paragraph Management:
Its a method like this :
Page updatePage(String token, Page page, PageUpdateOptions pageUpdateOptions)
Hi Tian.i have same problem on confluence.i have a page on that where i have a table on which i want to add row dynamically from my code.will you please share some helpfull things by which i would solve my problem. i read out atlassian doucmentation and they said that xml-rpc has deprecated.so how to use rest api for that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might want to review what API is available using the REST API Browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Timothy I am trying to update page content using POSTMAN . I am sending empty as ancestor id because for my test page ancestor id is blank.Getting below error
"Instantiation of [simple type, class com.atlassian.confluence.api.model.content.id.ContentId] value failed: ContentId string must not be null or empty (through reference chain: com.atlassian.confluence.api.model.content.Content[\"ancestors\"]->com.atlassian.confluence.api.model.content.Content[\"id\"])"
What should I pass for ancestor id if ancestor id is blank or null.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.