Repository navigation
Caused by: com.gooddata.GoodDataRestException: 415: [request_id=xyz] Content type 'application/xml;charset=UTF-8' not supported #837
Copy link
Copy link
Open
Labels
Description
Having trouble getting the Afm execution working.
Caused by: com.gooddata.GoodDataRestException: 415: [request_id=tzRYVbhAWy3Z8aTS] Content type 'application/xml;charset=UTF-8' not supported
Project insclixProject = goodDataService.getProjectService().getProjectById("XYZ");
ExecuteAfmService executeAfmService = goodDataService.getExecuteAfmService();
MetadataService metadataService = goodDataService.getMetadataService();
Attribute attr = metadataService.getObj(insclixProject, Attribute.class, Restriction.title("PaymentMethod"));
Metric metric = metadataService.getObj(insclixProject, Metric.class, Restriction.title("@NetUnits"));
Afm afm = new Afm()
// How
.addAttribute(new AttributeItem(new IdentifierObjQualifier(attr.getDefaultDisplayForm().getIdentifier()), "a1"))
// What
.addMeasure(new MeasureItem(new SimpleMeasureDefinition(new UriObjQualifier(metric.getUri())), "m1"));
// TODO Filter
Execution execution = new Execution(afm);
ExecutionResponse response = executeAfmService.executeAfm(insclixProject, execution);
logger.info(response.getExecutionResultUri());
logger.info(response.toString());Results in:
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.insclix.dashboard.EmbeddedWebApplication.main(EmbeddedWebApplication.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
Caused by: com.gooddata.GoodDataException: Unable to execute AFM
at com.gooddata.sdk.service.executeafm.ExecuteAfmService.executeAfm(ExecuteAfmService.java:77)
at com.insclix.dashboard.DevIntitializer.lambda$testData$0(DevIntitializer.java:103)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813)
... 10 common frames omitted
Caused by: com.gooddata.GoodDataRestException: 415: [request_id=e0WU2jcSXi0r9LAb] Content type 'application/xml;charset=UTF-8' not supported
at com.gooddata.sdk.service.util.ResponseErrorHandler.handleError(ResponseErrorHandler.java:55)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:778)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:736)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:414)
at com.gooddata.sdk.service.executeafm.ExecuteAfmService.executeAfm(ExecuteAfmService.java:71)
... 12 common frames omitted
I wasn't able to find any resource on this particular issue.
Any help is appreciated.
Reactions are currently unavailable
Activity
BenDol commentedon Aug 20, 2019
Manually overriding the
Content-Typeheader in the settings resolves this issue:but now I'm getting:
BenDol commentedon Aug 20, 2019
Okay so the reason the XML content type is added is because the
RestTemplateadds a theMappingJackson2XmlHttpMessageConvertermessage converter that processes the request. So removing this from theRestTemplatemessage converters resolves the issue. Might need to explicitly define what message converter is used.jimirocks commentedon Aug 21, 2019
@BenDol thanks for reporting the issue - just to clarify:
liry commentedon Aug 21, 2019
FYI: ad 1) no, logs say that "GoodData-Java-SDK/2.34.0+api1" version was used
BenDol commentedon Aug 21, 2019
I changed to use the latest version
3.0.0-RC.3+api3while trying to resolve it, but @liry is correct I initially was using2.34.0+api1. The issue occurs in either.GoodData: 3.0.0-RC.3+api3
Spring: 5.1.5.RELEASE
The reason I'm experiencing this is that the RestTemplate detects what libraries you have in your classpath and add the message converters to the list and for what ever reason the
MappingJackson2XmlHttpMessageConverteris being used (likely its just the first in the list before JSON). We need to make sure theRestTemplatefavors theMappingJackson2HttpMessageConverter.RestTemplate:
If you want to reproduce the issue just add
Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-xmlto your project.jimirocks commentedon Sep 16, 2019
@BenDol thanks for investigation and sorry for inactivity due to vacancies. We will try to find the way for ensuring the correct set of converters when GoodData is created.
At the same time I suppose you resolved the situation by excluding dataformat-xml from classpath?