Unsupported Media Type when calling import API

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:

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

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


HTTP/1.1 415 Unsupported Media Type

Whereas a simple curl does work:

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
== Info: Connected to localhost ( 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
<= 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
=> Send data, 3145 bytes (0xc49)
0000: {"attributes":...
0c40: ces":[]}.
=> Send data, 48 bytes (0x30)
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.

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.

1 Like

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