본문 바로가기

error records

[elasticsearch] "Content-Type header [application/x-www-form-urlencoded] is not supported","status":406

반응형


elasticSearch에서 PUT 또는 POST를 하는 경우 나온 에러 

 

"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406

 

elasticsearch 6.0 이후부터는 content-type을 꼭 넣어야 한다고! 

 

아래와 같은 명령어를 

curl -XPOST http://localhost:9200/classes/1/ -d ' {"title": "acb", "subject": "def"}'
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}%

 

이렇게 옵션을 추가해주니 되었다. 

curl -XPOST http://localhost:9200/classes/1/ -H'Content-Type: application/json' -d ' {"title": "acb", "subject": "def"}'
{"_index":"classes","_type":"1","_id":"Y8p3HIAB0VdubgSLszWG","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}%

 

 

반응형