Error uploading ndjson files to /api/saved_objects/_import

Hi, we are trying to build 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

Please note, we are using powershell scripting.