Possible Bug? Content-Type header in API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CXƆ
    Junior Member
    • Jun 2024
    • 3

    Possible Bug? Content-Type header in API

    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:
    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'
    Additional Information:

    This error prevents the implementation of simple logic to process JSON responses based on the Content-Type header.

    Best regards
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Fixed: https://github.com/espocrm/espocrm/c...10f66450ce4a0a

    Note that you can use GET api/v1/App/user request to check connection.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • CXƆ
      Junior Member
      • Jun 2024
      • 3

      #3
      Thank you much!

      Comment

      Working...