Search code examples
bugzilla

Bugzilla 5.0 REST API Authentication in headers


Using the Bugzilla 5.0 REST API, how do I send the API key in a header?

The following works with a 200 response and creates a bug:

curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
--data "@$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug?Bugzilla_api_key=ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"

But sending it in the header returns a 401:

curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
-H "X-BUGZILLA-API-KEY: ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"
--data "@$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug"

How do I send the API Key in the headers instead of the Query string?


Solution

  • I think you are using stable version of Bugzilla, version 5.0.4, according to the documentation for Rest API 5.0.4, it does not support X-BUGZILLA-API-KEY header for authentication.

    However, latest version 5.1.2 has support for allowing api key in the header.

    Alternatively, authentication credentials can be provided via one of the following headers:

    X-BUGZILLA-LOGIN

    X-BUGZILLA-PASSWORD

    X-BUGZILLA-API-KEY

    X-BUGZILLA-TOKEN

    Credentials passed as part of the query string take precedence over the header credentials.