w97802
w97802

Reputation: 121

400 Bad Request: invalid header name with curl POST request

I am trying to make a post request to an elastic search endpoint. The api key is correct and I was taking reference from this link: https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html for the api key format. my curl request

curl -H "Authorization:ApiKey xxxxx" 
\ -H "Content-Type:application/x-ndjson 
-XPOST "https://712bbxxx/tttt/_bulk" 
--data-binary "@sss.json"

the error message:

curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
400 Bad Request: invalid header name

I am pretty sure the quotes symbol & the spacing should be correct. may I ask if you have any idea what's wrong?

Upvotes: 0

Views: 1611

Answers (1)

Matthias
Matthias

Reputation: 3980

Maybe you forgot to close quotes for the content-type header, try

-H "Content-Type:application/x-ndjson"

Upvotes: 2

Related Questions