Piwigo API returns wrong mediatype #1615

Closed
opened 2026-10-05 00:50:23 +02:00 by adam · 0 comments
Owner

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.
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. ``` <!-- github-sync-id:1524142030 -->
adam closed this issue 2026-10-05 00:50:23 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1615