Skip to content

404 error returned on getUser api call #185

@kahuwi

Description

@kahuwi

Version info

  • intercom-php version: 2.0.0
  • PHP version: 5.6

Expected behavior

when user is not in intercom and getUser is called, the api should return with status with the user not found in the result

Actual behavior

api never returns, after further investigation guzzle dies on the 404 error returned by intercom api call. Page exists, has response code, but the http status of 404 causes guzzle to die.

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.intercom.io/users?email=expiration%40test.com resulted in a 404 Not Found response: {"type":"error.list","request_id":"aomm6mt35nhsscst6fhg","errors":[{"code":"not_found","message":"User Not Found"}]} ' in /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107 Stack trace: #0 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /datadisk/vhosts/blueprintprep.co in /datadisk/vhosts/blueprintprep.com/myrest/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 107

Steps to reproduce (as granular as possible, including screenshots where appropriate)

  1. use this code:
require_once 'vendor/autoload.php';
use Intercom\IntercomClient;
$client = new IntercomClient('YOUR TOKEN GOES HERE',null);
echo 'Client Defined<br>';
$user = $client->users->getUsers(["email" => "bogus@noserver.com"]);
echo $user->id;
echo '<br>';
$delete_user = $user->id;
echo $user->name;
echo '<br>';
$client->users->deleteUser($delete_user);
  1. Run code from 1 and you will see the Client Defined, and the error. However none of the other echo are seen since the getUsers call never returned.

  2. Intercom is overloading the 404 to mean user not found. The page is found and has the proper response data to indicate user not found. However, since the http status is 404 and guzzle sees as a page not found guzzle errors out. Intercom needs to return 200 or intercom api needs to handle the 404 and return the response back up the line so I can handle it in my codebase.

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions