Bad Request on POST to API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vladimir.d
    Junior Member
    • May 2021
    • 17

    Bad Request on POST to API

    We are working on 3CX integration and we have found API didn't work properly when 'Content-Type: application/json; charset=utf-8' header is passed in requests.
    It just returns 400 error - Bad Request.

    The reason of that is the content type is strictly hardcoded in 94 line of `application/Espo/Core/ControllerManager.php`.

    PHP Code:
    if ($data && $request->getContentType() === 'application/json') {
        $data = json_decode($data);
    } 
    
    As a quick workaround we had to patch the file as follows:

    PHP Code:
    if ($data && stripos($request->getContentType() ,'application/json') !== false) {
       $data = json_decode($data);
    } 
    
    Could you fix it in upcoming 6.1 and 7.0 releases?

    Another thread related to this issue is
    https://forum.espocrm.com/forum/deve...ost-to-account

    Related thread on 3CX forum:
    Hi, Could you please explain what's wrong with Create Contact Record request? We get the following error on Test: Request text: https://crm.espocrm.com/api/v1/Contact Request message: {"phoneNumber":"12345678","firstName":"New","lastName":"3CX Contact 12345678"} System.Exception: Server...
    Last edited by vladimir.d; 10-22-2021, 12:40 PM.
  • yuri
    Member
    • Mar 2014
    • 8495

    #2
    I believe it was fixed in 7.0.
    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

    Working...