Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

confluence rest api response json to java entity

shenghong yao
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 3, 2017

String auth = Base64.getEncoder().encodeToString("admin:admin".getBytes()); CloseableHttpClient httpClient = HttpClients.createDefault();

HttpGet httpGet = new HttpGet("http://localhost:8090/rest/api/content/688131"); httpGet.addHeader("Authorization", "Basic " + auth);

CloseableHttpResponse response = httpClient.execute(httpGet);

HttpEntity entity = response.getEntity();

String strResult = EntityUtils.toString(entity);

ObjectMapper mapper = new ObjectMapper();

//JsonContentProperty content = mapper.readValue(strResult, JsonContentProperty.class);

Content content = mapper.readValue(strResult, Content.class);

Above code is not work because com.atlassian.confluence.api.model.content.Content is not match. Which entity is match? Should I have to customize the entity?

1 answer

0 votes
Fabio Racobaldo _Catworkx_
Community Champion
April 22, 2026

Hi @shenghong yao ,

 

Content is not the correct class for REST JSON deserialization.You should implement your own DTO that matchs exaclty the rest api return value structure.
Hope this helps,
Fabio

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events