Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piwigo API returns wrong mediatype #1847

Closed
mingan666 opened this issue Jan 7, 2023 · 0 comments · May be fixed by #1885
Closed

Piwigo API returns wrong mediatype #1847

mingan666 opened this issue Jan 7, 2023 · 0 comments · May be fixed by #1885

Comments

@mingan666
Copy link

When using format=json on the api, the wrong mediatype is returned.
This causes a problem when using different frameworks in java since automatic decoding is not supported.

For example the following code snippet will return an exception:

ClientConfig clientConfig = new ClientConfig().register(GsonMessageBodyHandler.class);
Client client = ClientBuilder.newClient(clientConfig);
Response response = client.target("https://<hostname>")
   .path(String.format("ws.php"))
   .queryParam(FORMAT_JSON.getKey(), FORMAT_JSON.getValue())
   .queryParam(IMAGE_INFO.getKey(), IMAGE_INFO.getValue())
   .queryParam(IMAGE_ID, imageId)
   .request(MediaType.APPLICATION_JSON).get();
return response.readEntity(PiwigoResponse.class);

Will send a request url: https://<hostname>/ws.php?format=json&method=pwg.images.getInfo&image_id=339

And result in an exception:

org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/plain;charset=utf-8, type=class <package>.PiwigoResponse, genericType=class <package>.PiwigoResponse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant