elastic / elastic/docs-content

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

Open
#3,149 1 comment 0 reactions 0 assignees View on GitHub
api-feedback Team:Developer
Dominant language
No language data
Stars
47
Forks
261
Avg merge
3d 12h
Merged PRs (30d)
116

Description

### Was the documentation helpful?

Yes

### What documentation page is affected

- https://www.elastic.co/docs/api/doc/kibana/operation/operation-post-fleet-epm-packages
- Actually all Kibana API documentation pages

### 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]( https://www.elastic.co/docs/api/doc/kibana/authentication#doc-authentication-api-key-auth).

### Content-Type Header

This issue only affect the page [(Fleet API) Install a package by upload
](https://www.elastic.co/docs/api/doc/kibana/operation/operation-post-fleet-epm-packages)

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:

```json
{
"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`).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.