Error content type header application x www form urlencoded is not supported

I used to have ElasticSearch 5.2, and just upgraded to 6.0. I am trying to create an index template following guide here, but got error Content-Type header [application/x-www-form-urlencoded] is...

I used to have ElasticSearch 5.2, and just upgraded to 6.0.

I am trying to create an index template following guide here, but got error

Content-Type header [application/x-www-form-urlencoded] is not supported

My query is

curl -X PUT localhost:9200/_template/template_1 -d '
{
  "index_patterns": ["te*", "bar*"],
  "mappings": {
    "type1": {
      "properties": {
        "host_name": {
          "type": "keyword"
        }
      }
    }
  }
}'

ivanleoncz's user avatar

ivanleoncz

8,4326 gold badges56 silver badges48 bronze badges

asked Nov 29, 2017 at 4:16

Barry Leishman's user avatar

Barry LeishmanBarry Leishman

1,7932 gold badges7 silver badges7 bronze badges

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, as explained in this post

Starting from Elasticsearch 6.0, all REST requests that include a body must also provide the correct content-type for that body.

answered Nov 29, 2017 at 4:24

kgf3JfUtW's user avatar

3

The solution is to add Content-Type: application/json header

curl -XPUT 'localhost:9200/_template/template_1' 
  -H 'Content-Type: application/json' 
  -d '**your query**'

Patryk's user avatar

Patryk

21.7k41 gold badges121 silver badges239 bronze badges

answered Jan 23, 2019 at 9:02

Z.LI's user avatar

Z.LIZ.LI

3492 silver badges11 bronze badges

0

"{ "name": { "first": {} }, "address": [ { "address1":"lane" } ] } "

In Windows, when you give JSON as a parameter, use double quotes only. Use escape character.

David Buck's user avatar

David Buck

3,67235 gold badges33 silver badges35 bronze badges

answered Jun 15, 2020 at 13:39

charlie9526's user avatar

1

Slide 1

Most trusted JOB oriented professional program

DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2

DevOps to DevSecOps – Learn the evolution

DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2

Get certified in the new tech skill to rule the industry

Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2

Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2

Gain expertise and certified yourself

Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3

AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow

next arrow

elasticsearch-error-content-type-header

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"]
}
'
  • Author
  • Recent Posts

Rajesh Kumar

Mentor for DevOps — DevSecOps — SRE — Cloud — Container & Micorservices at Cotocus

Join my following certification courses…
— DevOps Certified Professionals (DCP)
— Site Reliability Engineering Certified Professionals (SRECP)
— Master in DevOps Engineering (MDE)
— DevSecOps Certified Professionals (DSOCP)
URL — https://www.devopsschool.com/certification/

My Linkedin — https://www.linkedin.com/in/rajeshkumarin
My Email — contact@DevOpsSchool.com

Rajesh Kumar

Spring boot, h2.
Дао

ProjectRepository extends JpaRepository<Project, Long>...

В контроллере

@PostMapping("/projects")
    public Project createProject(@Valid @RequestBody Project project) {
        return projectRepository.save(project);
    }

Post запрос выдаёт:

2020-07-08 11:23:25.544 DEBUG 11636 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header

java.io.EOFException: null
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1231) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1141) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:780) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:356) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_251]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at java.lang.Thread.run(Unknown Source) [na:1.8.0_251]
2020-07-08 11:23:25.545 DEBUG 11636 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor   : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@27f578d4:org.apache.tomcat.util.net.NioChannel@7e6521ae:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:50099]], Status in: [OPEN_READ], State out: [CLOSED]
2020-07-08 11:23:25.546 DEBUG 11636 --- [nio-8080-exec-2] o.apache.tomcat.util.threads.LimitLatch  : Counting down[http-nio-8080-exec-2] latch=2
2020-07-08 11:23:25.546 DEBUG 11636 --- [nio-8080-exec-2] org.apache.tomcat.util.net.NioEndpoint   : Calling [org.apache.tomcat.util.net.NioEndpoint@3cee8c55].closeSocket([org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@27f578d4:org.apache.tomcat.util.net.NioChannel@7e6521ae:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:50099]])
2020-07-08 11:23:25.582 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Set query string encoding to UTF-8
2020-07-08 11:23:25.593 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    : Security checking request POST /projects/
2020-07-08 11:23:25.594 DEBUG 11636 --- [nio-8080-exec-1] org.apache.catalina.realm.RealmBase      :   No applicable constraints defined
2020-07-08 11:23:25.603 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.a.jaspic.AuthConfigFactoryImpl     : Loading persistent provider registrations from [C:Userssur-pAppDataLocalTemptomcat.8000510046453634187.8080confjaspic-providers.xml]
2020-07-08 11:23:25.604 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    : Not subject to any constraint
2020-07-08 11:23:25.612  INFO 11636 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-07-08 11:23:25.612  INFO 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-07-08 11:23:25.612 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Detected StandardServletMultipartResolver
2020-07-08 11:23:25.626 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2020-07-08 11:23:25.626  INFO 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 14 ms
2020-07-08 11:23:25.647 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Set encoding to UTF-8
2020-07-08 11:23:25.647 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Start processing with input [title=second]
2020-07-08 11:23:25.648 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : POST "/projects/", parameters={masked}
2020-07-08 11:23:25.663 DEBUG 11636 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to ru.surpavel.bugtrackingsystem.controller.ProjectController#createProject(Project)
2020-07-08 11:23:25.664 DEBUG 11636 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2020-07-08 11:23:25.719 DEBUG 11636 --- [nio-8080-exec-1] .w.s.m.m.a.ServletInvocableHandlerMethod : Could not resolve parameter [0] in public ru.surpavel.bugtrackingsystem.entity.Project ru.surpavel.bugtrackingsystem.controller.ProjectController.createProject(ru.surpavel.bugtrackingsystem.entity.Project): Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Hi Guys,

I am trying to upload a log file in the ElasticSearch engine using the PUT command. But it is showing me the below-given error.

$ curl -X PUT http://ElasticEngineIP:9200/mylogdb --data-binary @log.json 
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

Can anyone help me to resolve this error?







Jun 16, 2020


in DevOps Tools


by



• 38,240 points





4,115 views



1 answer to this question.

Hi@akhtar,

In your command, you have to mention the Content-Type of your log file. You can use the below-given command.

$ curl -X PUT -H 'Content-Type: application/json' http://ElasticEngineIP:9200/mylogdb --data-binary @log.json

I hope this will help you. 






answered

Jun 16, 2020


by
MD


• 95,420 points



Related Questions In DevOps Tools

  • All categories

  • ChatGPT
    (4)

  • Apache Kafka
    (84)

  • Apache Spark
    (596)

  • Azure
    (131)

  • Big Data Hadoop
    (1,907)

  • Blockchain
    (1,673)

  • C#
    (141)

  • C++
    (271)

  • Career Counselling
    (1,060)

  • Cloud Computing
    (3,446)

  • Cyber Security & Ethical Hacking
    (147)

  • Data Analytics
    (1,266)

  • Database
    (855)

  • Data Science
    (75)

  • DevOps & Agile
    (3,575)

  • Digital Marketing
    (111)

  • Events & Trending Topics
    (28)

  • IoT (Internet of Things)
    (387)

  • Java
    (1,247)

  • Kotlin
    (8)

  • Linux Administration
    (389)

  • Machine Learning
    (337)

  • MicroStrategy
    (6)

  • PMP
    (423)

  • Power BI
    (516)

  • Python
    (3,188)

  • RPA
    (650)

  • SalesForce
    (92)

  • Selenium
    (1,569)

  • Software Testing
    (56)

  • Tableau
    (608)

  • Talend
    (73)

  • TypeSript
    (124)

  • Web Development
    (3,002)

  • Ask us Anything!
    (66)

  • Others
    (1,929)

  • Mobile Development
    (263)

Subscribe to our Newsletter, and get personalized recommendations.

Already have an account? Sign in.

Понравилась статья? Поделить с друзьями:
  • Error content and map of this source is not available only size is supported
  • Error container dev rdisk1 is mounted
  • Error contacting the parsoid restbase server http 500
  • Error could not find a version that satisfies the requirement pygame from versions none
  • Error could not find a version that satisfies the requirement pip3 from versions none