To authenticate against the Snipe-IT API, you'll need to pass an
Accept: application/json and
Content-Type: application/json header with every request.
It should look something like this, if your API key were
In reality, your API Key will be much longer than that, but you get the idea.
For example, using the Guzzle library:
$accessToken = 'MY-AWESOME-API-KEY'; $response = $client->request('GET', '/api/users', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer '.$accessToken, ], ]);
Be sure to include BOTH the Content-Type AND Accept headers with your request!
If your API request returns a login page (or any HTML page) and you're certain you're passing the Bearer token correctly in the
Authorizationheader, double-check that you are passing both the
Acceptheaders, and that the value of those headers is