Response in text/plain instead of application/json #964

Open
opened 2026-10-05 00:25:50 +02:00 by adam · 3 comments
Owner

If I query the webservice with format=json, I expect the response to be in application/json. It is in text/plain. Could it be corrected?

Latest piwigo, php 5.6.40.

If I query the webservice with format=json, I expect the response to be in application/json. It is in text/plain. Could it be corrected? Latest piwigo, php 5.6.40. <!-- github-sync-id:512309831 -->
Author
Owner

In fact, most answers are in JSON format but the server returns plain text messages when it encounters errors, which is problematic for third party apps.

In fact, most answers are in JSON format but the server returns plain text messages when it encounters errors, which is problematic for third party apps. <!-- github-comment-id:546590870 -->
Author
Owner

I have looked into this in detail and you are perfectly right. Answers are provided in JSON format (except when the server encounters an error) but the header of all answers contains a content type = text/plain instead of application/json. The content type should be application/json as described by RFC4627.

I have looked into this in detail and you are perfectly right. Answers are provided in JSON format (except when the server encounters an error) but the header of all answers contains a content type = `text/plain` instead of `application/json`. The content type should be `application/json` as described by [RFC4627](https://www.ietf.org/rfc/rfc4627.txt). <!-- github-comment-id:547553723 -->
Author
Owner

I have replaced text/plain with application/json in the file /include/ws_protocols/json_encoder.php and everything works fine with the iOS app awaiting for JSON data. However, web browsers have issues and loading the tools/ws.htm page returns an 'error when parsing JSON string'. So some work needs to be done to fix this issue before switching to 'application/json'.

I have replaced `text/plain` with `application/json` in the file `/include/ws_protocols/json_encoder.php` and everything works fine with the iOS app awaiting for JSON data. However, web browsers have issues and loading the `tools/ws.htm` page returns an 'error when parsing JSON string'. So some work needs to be done to fix this issue before switching to 'application/json'. <!-- github-comment-id:547567677 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#964