Announcement

Collapse
No announcement yet.

Possible Bug? Content-Type header in API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Note that you can use GET api/v1/App/user request to check connection.

    Comment


    • #3
      Thank you much!

      Comment

      Working...
      X