Error uploading ndjson files to /api/saved_objects/_import : returned 406

Hi, we are trying to build powershell script to import the ndjson (Diskutilization.ndjson) file into Kibana.

$upload_object = $es_url + “/api/saved_objects/_import?overwrite=true”

$form = @{
file = Get-Content -Raw -Path “Diskutilization.ndjson”
minorEdit = “true”
}

Invoke-WebRequest -UseBasicParsing -Uri $upload_object -Credential $credentials -Method ‘POST’ -Headers @{
‘Content-Type’ = ‘multipart/form-data’
‘kbn-xsrf’ = ‘true’
‘securitytenant’ = ‘Observability’
} -Form $form -WebSession $websession

We are getting the below error,

{“error”:“Content-Type header [multipart/form-data; boundary=“ad6f415c-0f94-4ba4-99f0-bca0132967a1”] is not supported”,“status”:406}

We also tried ‘Content-Type’ = ‘application/json’. it did not work either. same error.

Not able to resolve this, can you please help.

Regards
Lokesh V

Hey @lokeshv1989,

Can you try removing the ‘Content-Type’ = ‘multipart/form-data’ header altogether? You might also try Content-Type: application/x-ndjson, but I think you will have better luck if you just omit it entirely.

Thanks
Brian

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