Announcement

#1 2022-12-31 13:04:07

duck
Member
2022-12-27
13

Piwigo API returns wrong mediatype

Hi,

I'm trying to integrate towards the web api through a java application, but I'm having problems reserializing the response.
However, the mediatype returned seems to be "text/plain;charset=utf-8", but I would expect to be "application/json".

Is there any reason why the wrong mediatype is returned? Its causing me the following issue:

My code sending the request:

        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);

Which result in a request with the following target url:

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

However, when checking the response, the mediatype is wrong:
response.getMediaType() gives me "text/plain;charset=utf-8", but I would expect to be "application/json"

This results in the decoding not working as expected. The GsonMessageBodyHandler will not be found since its for "application/json" and the return statement will throw 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.

Offline

 

#2 2023-01-07 12:39:29

duck
Member
2022-12-27
13

Re: Piwigo API returns wrong mediatype

Hi,

Could really use some input here...
Is there anyway to get piwigo to return the correct mediatype on the api?
Or is this a bug and should I open an issue on github?

Maybe I could get some pointer where to start looking in the piwigo code?

Offline

 

#3 2023-01-07 15:54:08

erAck
Only trying to help
2015-09-06
1998

Re: Piwigo API returns wrong mediatype

That seems to be wrong-wired in include/ws_protocols/json_encoder.php function getContentType().


Running Piwigo at https://erack.net/gallery/

Offline

 

#4 2023-01-07 22:02:50

duck
Member
2022-12-27
13

Re: Piwigo API returns wrong mediatype

Thanks!
I've create a pull request and hopefully it might be included in the next release.

Offline

 

#5 2023-01-07 22:17:31

erAck
Only trying to help
2015-09-06
1998

Re: Piwigo API returns wrong mediatype


Running Piwigo at https://erack.net/gallery/

Offline

 

#6 2023-02-11 10:44:13

duck
Member
2022-12-27
13

Re: Piwigo API returns wrong mediatype

So, it seems my fix was not part of the 13.5.0 release...
Do I need to do something else to make sure it get the fix merged?

Offline

 

#7 2023-02-11 12:16:52

erAck
Only trying to help
2015-09-06
1998

Re: Piwigo API returns wrong mediatype

No idea. My personal impression is the Piwigo team (to be fair, it's only 2-3 people) is really bad at merging, reviewing or even recognizing code contributions in pull requests, rarely providing feedback. It got better in summer/autumn last year but then went to sleep again.


Running Piwigo at https://erack.net/gallery/

Offline

 

#8 2023-02-11 13:19:43

Katryne
Member
2016-12-03
365

Re: Piwigo API returns wrong mediatype

You are harsh, erAck : the issue I reported on Github found a solution in 6 days last November and was included in the new release. Of course, it was a tiny issue and the report took place just the week before the new release.


http://photos.katrynou.fr/ v.14.1.0 https://album.chauvigne.info/ v.13.8.0
Système d'exploitation: Linux - Hébergeur 1&1-Ionos PHP: 8.0.28 - MySQL: 5.7.38
Bibliothèque graphique: External ImageMagick 6.9.10-23

Offline

 

#9 2023-02-11 16:00:58

BigIsland270972
Member
Norway
2022-03-15
374

Re: Piwigo API returns wrong mediatype

erAck wrote:

No idea. My personal impression is the Piwigo team (to be fair, it's only 2-3 people) is really bad at merging, reviewing or even recognizing code contributions in pull requests, rarely providing feedback. It got better in summer/autumn last year but then went to sleep again.

Yeah they REALLY should get more people onboard. Everything from coding to customer support is too little to late.


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

#10 2023-02-11 16:47:57

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: Piwigo API returns wrong mediatype

I just replied on https://github.com/Piwigo/Piwigo/pull/1 … 1426804255 (this problem is not as easy as it seems)

Yeah they REALLY should get more people onboard.

I would be happy to do so.

Everything from coding to customer support is too little too late.

I agree. We need to be better at this.

Offline

 

#11 2023-02-11 16:49:40

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: Piwigo API returns wrong mediatype

erAck wrote:

My personal impression is the Piwigo team (to be fair, it's only 2-3 people)

If you consider only "dev team", you're right. We're not many on Piwigo core.

erAck wrote:

is really bad at merging, reviewing or even recognizing code contributions in pull requests, rarely providing feedback. It got better in summer/autumn last year but then went to sleep again.

Thank you for seeing that I made a serious effort on pull-requests last summer :-) I indeed stopped this effort but I have to do it again and keep it as a goal.

Offline

 

#12 2023-02-11 22:11:21

duck
Member
2022-12-27
13

Re: Piwigo API returns wrong mediatype

I just updated the thread with a suggestion for a work around.

If I may add my opinion as a new user, it would have nice to get that information.
I guess some information back when people are trying to contribute is appreciated?

May seem as a small issue, but it is really messing everything upp for me.

Offline

 

#13 2023-02-11 23:22:22

erAck
Only trying to help
2015-09-06
1998

Re: Piwigo API returns wrong mediatype

Katryne wrote:

You are harsh, erAck

May sound so, what I'm only complaining about is, pull-requests are sitting there without feedback for weeks and months or even years; lingering for a while is ok but then either merge, or say "yes, but" to iterate, or tell why not and eventually close. Additionally, the wider the code gap between contribution and current code, the more risk of merge conflicts evolves over time, so it's also easier to handle PRs timely.

plg wrote:

Thank you for seeing that I made a serious effort on pull-requests last summer :-) I indeed stopped this effort but I have to do it again and keep it as a goal.

Yes it was to be noticed :-)

You keep contributors happy contributing when they see their contributions acknowledged :)


Running Piwigo at https://erack.net/gallery/

Offline

 

#14 2023-02-19 10:04:22

duck
Member
2022-12-27
13

Re: Piwigo API returns wrong mediatype

After another week has gone, I've not had any feedback on my ideas regarding an alternative solution.
I'll give another week, but then I will try to find a more permanent workaround for me personally (I'll try to replace the test string in a dockerfile instead of just running the linxserver image)...
I will not be putting more time and trying to fix this in the project as feedback from the developers is so poorly...

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact