无法将JASPER REST API响应解析为ReportExecutionDescriptor模型

时间:2019-03-05 05:57:10

标签: java rest resttemplate jasperserver

我正在尝试使用Jasper Server的REST API-(http://:/ jasperserver [-pro] / rest_v2 / reportExecutions)。我正在关注(https://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/running-report-asynchronously

上的文档

下面是我的代码:

@RequestMapping(method = RequestMethod.GET, value = "/reportExecutions")
@ResponseBody
public ReportExecutionDescriptor getReportExecutionDesc() {

    UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(URL_V2);
    uriBuilder.pathSegment("reportExecutions/");

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));

    HttpEntity<ReportExecutionRequest> entity = new HttpEntity<ReportExecutionRequest>(getReportExecutionRequestModel(), headers);

    ParameterizedTypeReference<ReportExecutionDescriptor> responseType = new ParameterizedTypeReference<ReportExecutionDescriptor>() {
    };
    ResponseEntity<ReportExecutionDescriptor> restResponse =
            restTemplate.exchange(
                    uriBuilder.build().toUriString(),
                    HttpMethod.POST,
                    entity,
                    responseType
                    );
    return restResponse.getBody();
}

当我尝试使用Map而不是ReportExecutionDescriptor时,我能够得到响应。

ResponseEntity<HashMap> restResponse =
                restTemplate.exchange(
                        uriBuilder.build().toUriString(),
                        HttpMethod.POST,
                        entity,
                        HashMap.class
                        );

我得到的错误是:

java.lang.IllegalArgumentException: Conflicting setter definitions for property "parameters":
com.jaspersoft.jasperserver.dto.common.ErrorDescriptor#setParameters(1 params) vs
com.jaspersoft.jasperserver.dto.common.ErrorDescriptor#setParameters(1 params)at [Source: UNKNOWN; line: -1, column: -1]

0 个答案:

没有答案