Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am facing a challenge using tRest to send GET requests to an API. The same task is currently executed through a powershell script and works fine, however there's room for improvement and I am now looking to get this done through a TOS job.
I am sending a first request with tRest and get a list of clients using tExtractJSONFields = works fine.
Now, I am looking to send another request to a different endpoint, which works perfectly fine on my web browser. However when executing my job tRest --> (main) --> tLogRow, I am getting the below java execution error:
Exception in component tREST_3 (APITest)
java.lang.IllegalArgumentException: Error parsing media type '200'
at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:80)
at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:53)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
at com.sun.jersey.api.client.ClientResponse.getType(ClientResponse.java:613)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:530)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:505)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:563)
at com.sun.jersey.api.client.WebResource.get(WebResource.java:182)
at local_project.apitest_0_1.APITest.tREST_3Process(APITest.java:700)
at local_project.apitest_0_1.APITest.runJobInTOS(APITest.java:1881)
at local_project.apitest_0_1.APITest.main(APITest.java:1732)
Caused by: java.text.ParseException: End of header
at com.sun.jersey.core.header.reader.HttpHeaderReaderImpl.getNextCharacter(HttpHeaderReaderImpl.java:219)
at com.sun.jersey.core.header.reader.HttpHeaderReaderImpl.next(HttpHeaderReaderImpl.java:184)
at com.sun.jersey.core.header.reader.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:112)
at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.valueOf(MediaTypeProvider.java:91)
at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(MediaTypeProvider.java:78)
... 10 more
Is it due to the response itself? (special character? encoding?)
Would you have any insight (using TOS for Data Integration 7.0.1)
Thank you !
Can you share your tRestClient configuration and some info on the API? A screenshot of the basic and advanced settings should be enough.
It's actually the tRest component that I am using and the configuration is pretty basic as only the URL has been filled in. You will find 2 screenshots of the configuration below.
The API can return either a JSON response or a CSV by adding the parameter &format=csv, but in either case I get the same error.
I am not clear about the difference between the tRest and the tRestClient components and in which situation using one rather than the other one, but as my first request returns a valid response, I assumed the second one should work the same way.
If using the tRestClient component with the same basic settings for the 1st request (which works fine), I get the below response :
"200|<?xml version="1.0" encoding="UTF-8"?>
<root><etc.....>"
If running the same with the second API request, I get the below error:
Exception in component tRESTClient_2 (APITest)
javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: Media type separator is missing
at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1157)
at org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:1126)
at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1051)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:897)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:866)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:431)
at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:611)
at local_project.apitest_0_1.APITest.tRESTClient_2Process(APITest.java:911)
at local_project.apitest_0_1.APITest.runJobInTOS(APITest.java:3768)
at local_project.apitest_0_1.APITest.main(APITest.java:3612)
Caused by: java.lang.IllegalArgumentException: Media type separator is missing
at org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.handleMediaTypeWithoutSubtype(MediaTypeHeaderProvider.java:191)
at org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.internalValueOf(MediaTypeHeaderProvider.java:80)
at org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.valueOf(MediaTypeHeaderProvider.java:66)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.toMediaType(JAXRSUtils.java:1711)
at org.apache.cxf.jaxrs.impl.ResponseImpl.getMediaType(ResponseImpl.java:248)
at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:331)
at org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:539)
at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1138)
... 9 more
I am just starting with Java and despite some time googling this, I did not find a solution.
Thank you.
I am still facing the same issue, however the same basic request returns perfectly valid results in Postman. Any idea what could cause this java error? What other information could help?
Thank you,
Regards
I think your content type is incorrect. Try using ....
"application/json"
You should at least see a different error message
Thanks for your feedback rhall_2_0, unfortunately I've tried that and I am getting the exact same error message...