Skip to content

[API]: curl Command Fixes: Incorrect API Key Header and Content-Type for Package Upload #3149

@herrBez

Description

@herrBez

Was the documentation helpful?

Yes

What documentation page is affected

Description

The example curl provided by the documentation has a handful of issues:

curl \
 --request POST 'https://localhost:5601/api/fleet/epm/packages' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/gzip; application/zip" \
 --header "kbn-xsrf: true" \
 --data-binary '@file'

API Key header

The first issue affects all Kibana API requests:

 --header "Authorization: $API_KEY" \

should be:

 --header "Authorization: ApiKey $API_KEY" \

(Note the additional ApiKey string). This is also reported in the introduction of the API Documentation.

Content-Type Header

This issue only affect the page (Fleet API) Install a package by upload

The following Content-Type header:

 --header "Content-Type: application/gzip; application/zip" \
 .. 
 --data-binary '@myfile.zip'

Does not work with Kibana. It will answer with the following error:

{
    "statusCode": 415,
    "error": "Unsupported Media Type",
    "message": "Unsupported media type application/gzip; application/zip. Please use 'application/gzip' or 'application/zip'"
}                     

To fix the command, we need to adjust the content-type to be only application/zip (or application/gzip if the file is a gzip).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions