I would like to report a possible bug that I encountered while developing a Python client for the API. This client is intended to test if the connection can be established. I solve this with a GET request to /api/v1/ - without performing any further action. I use HMAC as the authentication method.
EspoCRM Version: 8.2.4
Steps to Reproduce:
Expected Behavior:
If the Content-Type header is 'application/json', the response body should contain valid JSON.
Actual Behavior:
The Content-Type header is 'application/json', but the response body contains the string 'EspoCRM REST API', which is not valid JSON.
Error Log: Python error when trying to parse the response as JSON:
Response-Header:
Response Body:
Additional Information:
This error prevents the implementation of simple logic to process JSON responses based on the Content-Type header.
Best regards
EspoCRM Version: 8.2.4
Steps to Reproduce:
- Send a GET request to https://example.com/api/v1/
- Check the response headers and the response body
Expected Behavior:
If the Content-Type header is 'application/json', the response body should contain valid JSON.
Actual Behavior:
The Content-Type header is 'application/json', but the response body contains the string 'EspoCRM REST API', which is not valid JSON.
Error Log: Python error when trying to parse the response as JSON:
Code:
if response.headers.get('Content-Type', '').startswith('application/json'): return response.json() Error: Expecting value: line 1 column 1 (char 0)
Response-Header:
Code:
{ 'Server': 'openresty', 'Date': 'Mon, 24 Jun 2024 21:53:34 GMT', 'Content-Type': 'application/json', 'Content-Length': '16', 'Connection': 'keep-alive', 'X-App-Timestamp': '1719243103', 'Expires': '0', 'Last-Modified': 'Mon, 24 Jun 2024 21:53:34 GMT', 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Pragma': 'no-cache', 'Strict-Transport-Security': 'max-age=63072000; preload', 'X-Served-By': 'beispiel.de' }
Response Body:
Code:
b'EspoCRM REST API'
This error prevents the implementation of simple logic to process JSON responses based on the Content-Type header.
Best regards
Comment