Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-7191

REST DSL fails to handle content-type form-urlencoded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • fuse-7.0
    • jboss-fuse-6.3
    • Camel
    • None
    • Hide

      Please run attached fuse project as below to re-produce.

      How to run
      ===========================================
      $ mvn clean install
      $ mvn camel:run

      $ curl -X POST -H "content-type: application/json" -d '

      {"msg": "TEST"}

      ' http://localhost:9002/rest/test
      Camel Log=> [qtp1166359994-42] _route1 INFO ***

      {msg=TEST}

      RET Response=> "OK"

      $ curl -X POST -H "content-type: application/x-www-form-urlencoded" -d '

      {"msg": "TEST"}

      ' http://localhost:9002/rest/test
      Camel log=> Caused by: java.lang.IllegalArgumentException: Invalid parameter, expected to be a pair but was

      {"msg": "TEST"}

      at org.apache.camel.http.common.DefaultHttpBinding.populateRequestParameters(DefaultHttpBinding.java:257)
      at org.apache.camel.component.jetty.JettyRestHttpBinding.populateRequestParameters(JettyRestHttpBinding.java:35)
      at org.apache.camel.http.common.DefaultHttpBinding.readHeaders(DefaultHttpBinding.java:165)
      ... 18 more
      RET Response=> "Error 500 Server Error"

      Show
      Please run attached fuse project as below to re-produce. How to run =========================================== $ mvn clean install $ mvn camel:run $ curl -X POST -H "content-type: application/json" -d ' {"msg": "TEST"} ' http://localhost:9002/rest/test Camel Log=> [qtp1166359994-42] _route1 INFO *** {msg=TEST} RET Response=> "OK" $ curl -X POST -H "content-type: application/x-www-form-urlencoded" -d ' {"msg": "TEST"} ' http://localhost:9002/rest/test Camel log=> Caused by: java.lang.IllegalArgumentException: Invalid parameter, expected to be a pair but was {"msg": "TEST"} at org.apache.camel.http.common.DefaultHttpBinding.populateRequestParameters(DefaultHttpBinding.java:257) at org.apache.camel.component.jetty.JettyRestHttpBinding.populateRequestParameters(JettyRestHttpBinding.java:35) at org.apache.camel.http.common.DefaultHttpBinding.readHeaders(DefaultHttpBinding.java:165) ... 18 more RET Response=> "Error 500 Server Error"
    • 7.0 Sprint 16

      The requirement is that REST DSL need to accept "content-type: application/x-www-form-urlencoded".
      In Camel 2.17 – available in Fuse 6.3 – a new attribute will be available on the HTTP endpoints:
      mapHttpMessageBody=false

      https://access.redhat.com/solutions/2247391

      Using this attribute in REST DSL, but it does not work and there are errors.

              yfang@redhat.com Freeman(Yue) Fang
              rhn-support-vgohel Viral Gohel
              Jan Kasztura Jan Kasztura (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: