To fix this, add curl option -H ‘Content-Type: application/json’. This error is due to strict content-type checking introduced in ElasticSearch 6.0
curl -XPUT 'localhost:9200/products/mobiles/1?pretty' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
Response
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status" : 406
}
Solution
curl -XPUT 'localhost:9200/products/mobiles/1?pretty' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
Latest posts by Rajesh Kumar (see all)
- Top 10 Website Development Companies in Vadodara - December 20, 2024
- Compare SAST, DAST and RASP & its Tools for DevSecOps - December 19, 2024
- Comparing AWS, Azure, and Google Cloud in terms of services - December 19, 2024