Hi, everyone.
I want to update content using rest api
document link = https://developer.atlassian.com/cloud/confluence/rest/api-group-content/#api-api-content-id-put
The code written based on the example is as follows.
HttpResponse<String> response = Unirest.get("https://xxx/wiki/rest/api/content/{id}?expand=body.storage,version,ancestors")
.basicAuth("user_id", "token")
.header("Accept", "application/json")
.asString();
JSONObject page = new JSONObject(response.getBody());
page.getJSONObject("body").getJSONObject("storage").put("value", "<p>hello, world<p>");
int currentVersion = page.getJSONObject("version").getInt("number");
page.getJSONObject("version").put("number", currentVersion + 1);
HttpResponse<String> put = Unirest.put("https://xxx/wiki/rest/api/content/{id}")
.basicAuth("user_id", "token")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.body(page)
.asString();
System.out.println(put.getBody());return message
{"statusCode":400,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Must supply an incremented version when updating Content. No version supplied."}