# Unsupported Media Type when calling import API

**URL:** <https://discuss.elastic.co/t/unsupported-media-type-when-calling-import-api/311742>\
**Category:** Kibana\
**Created:** [August 9, 2022, 1:41pm UTC](https://discuss.elastic.co/t/unsupported-media-type-when-calling-import-api/311742 "2022-08-09T13:41:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Hartmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martin_hartmann/32/109413_2.png) [@Martin\_Hartmann](https://discuss.elastic.co/u/Martin_Hartmann)\
**Post date:** [August 9, 2022, 1:41pm UTC](https://discuss.elastic.co/t/unsupported-media-type-when-calling-import-api/311742/1 "2022-08-09T13:41:10Z")

</div>

Hi. We run Kibana in v 7.17.3 and when calling the /api/saved\_objects/\_imports API, we get a 415 - Unsupported Media Type error as response for some clients. Our go client doesn't work:

```auto
REQUEST:
POST /api/saved_objects/_imports?overwrite=true HTTP/1.1
Host: localhost:5601
User-Agent: Go-http-client/1.1
Content-Length: 3391
Accept: */*
Content-Type: multipart/form-data; boundary=2aec0dde0a75a0d6074e95a2685a0dd7ad58b5464b33e0c35834ca6277c8
Kbn-Xsrf: true
Accept-Encoding: gzip

--2aec0dde0a75a0d6074e95a2685a0dd7ad58b5464b33e0c35834ca6277c8
Content-Disposition: form-data; name="file"; filename="api-gateway.ndjson"
Content-Type: application/octet-stream

{"attributes":...

--2aec0dde0a75a0d6074e95a2685a0dd7ad58b5464b33e0c35834ca6277c8--
RESPONSE:
HTTP/1.1 415 Unsupported Media Type

```

Whereas a simple curl does work:

```auto
sh-4.2# curl -XPOST http://localhost:5601/api/saved_objects/_import?overwrite=true -H "kbn-xsrf: true" --form file=@/gitsync/git-sync/searches/api-gateway.ndjson --trace-ascii -
== Info: About to connect() to localhost port 5601 (#0)
== Info: Trying 127.0.0.1...
== Info: Connected to localhost (127.0.0.1) port 5601 (#0)
=> Send header, 265 bytes (0x109)
0000: POST /api/saved_objects/_import?overwrite=true HTTP/1.1
0039: User-Agent: curl/7.29.0
0052: Host: localhost:5601
0068: Accept: */*
0075: kbn-xsrf: true
0085: Content-Length: 3355
009b: Expect: 100-continue
00b1: Content-Type: multipart/form-data; boundary=--------------------
00f1: --------5a20e25412f8
0107:
<= Recv header, 23 bytes (0x17)
0000: HTTP/1.1 100 Continue
=> Send data, 162 bytes (0xa2)
0000: ------------------------------5a20e25412f8
002c: Content-Disposition: form-data; name="file"; filename="api-gatew
006c: ay.ndjson"
0078: Content-Type: application/octet-stream
00a0:
=> Send data, 3145 bytes (0xc49)
0000: {"attributes":...
0c40: ces":[]}.
=> Send data, 48 bytes (0x30)
0000:
0002: ------------------------------5a20e25412f8--
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK

```

Might there be anything, which curl does implicit, so that it works there? (We also tried "application/x-ndjson" as content type in the request parts). It would be nice if there could be some real world examples [in the documentation](https://www.elastic.co/guide/en/kibana/master/saved-objects-api-import.html).

---

<div class="post-metadata">

**Author:** ![Martin\_Hartmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martin_hartmann/32/109413_2.png) [@Martin\_Hartmann](https://discuss.elastic.co/u/Martin_Hartmann)\
**Post date:** [August 10, 2022, 11:19am UTC](https://discuss.elastic.co/t/unsupported-media-type-when-calling-import-api/311742/2 "2022-08-10T11:19:51Z")

</div>

It seems I found the reason for the weird behaviour. One time, we called the "imports" API and one time the "import" (Note the "s" at the end). It seems I accidently called an undocumented API.  
With the plain "import" API, everything works as expected.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 7, 2022, 11:20am UTC](https://discuss.elastic.co/t/unsupported-media-type-when-calling-import-api/311742/3 "2022-09-07T11:20:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
