9 Replies Latest reply: May 1, 2013 6:52 AM by GeospatialMarty RSS

    REST get request error 400 - Bad Request

    GeospatialMarty
      I am using APEX 4.2.1.00.08 to publish RESTful web services that query a table of place names.

      The db has NLS_CHARACTERSET of AL32UTF8 but I am getting this error only with foreign encoded text:

      400 - Bad Request
      The request path contains illegal characters

      How do I get foreign encoded text to work as the bind variable value of a REST service?
        • 1. Re: REST get request error 400 - Bad Request
          Colm Divilly
          GeospatialMarty wrote:
          I am using APEX 4.2.1.00.08 to publish RESTful web services that query a table of place names.

          The db has NLS_CHARACTERSET of AL32UTF8 but I am getting this error only with foreign encoded text:

          400 - Bad Request
          The request path contains illegal characters

          How do I get foreign encoded text to work as the bind variable value of a REST service?
          It would be helpful to tell us more about the RESTful Service, an example of the URI Template, an example of the URL that gives the above error.

          The range of legal characters is very restricted for URLs [1], and any non legal characters must be URL Encoded. It sounds like you have non URL legal characters in a URL you are forming. If you are producing a URL you need to make sure all parts of it are properly escaped, e.g. using UTL_URL.escape [2]

          [1] http://tools.ietf.org/html/rfc2396
          [2] http://sqldev.us.oracle.com:8080/svn/repos/SQLDEV/info?revision=69969
          • 2. Re: REST get request error 400 - Bad Request
            GeospatialMarty
            RESTful Service Module: sugg
            URI Template: q/{q}
            Method: GET

            Note that I am not creating the URL myself. In APEX under 'SQL Workshop' | 'RESTful Service' on the 'Resource Handler' page for this service, I am using the 'Set Bind Variables' button. When I click that button it takes my test value and launches the URL.


            Sample URL from APEX that queries for 'L' and does work: http://+internalserver+/apex/sugg/sugg/q/L

            Sample URL from APEX that queries for 'ロ' and doesn't work: http://+internalserver+/apex/sugg/sugg/q/ロ

            The previous sample URL after Firefox encodes it and doesn't work: http://+internalserver+/apex/sugg/sugg/q/%E3%83%AD


            Thanks for any advice.
            • 3. Re: REST get request error 400 - Bad Request
              Colm Divilly
              GeospatialMarty wrote:
              RESTful Service Module: sugg
              URI Template: q/{q}
              Method: GET

              Note that I am not creating the URL myself. In APEX under 'SQL Workshop' | 'RESTful Service' on the 'Resource Handler' page for this service, I am using the 'Set Bind Variables' button. When I click that button it takes my test value and launches the URL.


              Sample URL from APEX that queries for 'L' and does work: http://+internalserver+/apex/sugg/sugg/q/L

              Sample URL from APEX that queries for 'ロ' and doesn't work: http://+internalserver+/apex/sugg/sugg/q/ロ

              The previous sample URL after Firefox encodes it and doesn't work: http://+internalserver+/apex/sugg/sugg/q/%E3%83%AD
              I would expect that to work, if you have a full stack trace that would be useful, I need the whole thing not a shortened version to see where the problem originates. I will attempt to reproduce as well.
              >
              Thanks for any advice.
              • 4. Re: REST get request error 400 - Bad Request
                Colm Divilly
                >>
                Sample URL from APEX that queries for 'L' and does work: http://+internalserver+/apex/sugg/sugg/q/L

                Sample URL from APEX that queries for 'ロ' and doesn't work: http://+internalserver+/apex/sugg/sugg/q/ロ

                The previous sample URL after Firefox encodes it and doesn't work: http://+internalserver+/apex/sugg/sugg/q/%E3%83%AD
                I would expect that to work, if you have a full stack trace that would be useful, I need the whole thing not a shortened version to see where the problem originates. I will attempt to reproduce as well.
                I'm not able to reproduce the problem, for example this URL works as expected:

                http://apex.oracle.com/pls/apex/resteasy/i8n/q/%E3%83%AD

                Note this URL was produced by creating a RESTful Service, and binding a parameter to the 'ロ' value, The value was correctly escaped to the expected '%E3%83%AD' UTF-8 encoding. The only thing I can think of is that you may be running on Windows and your default JVM encoding may be cp1252 instead of UTF-8, leading to the decoding back to UTF-8 going wrong. A full stack trace from your logs (see here for details on how to turn logging on: [1]), would help identify if this is the case.

                [1] https://cdivilly.wordpress.com/2013/03/08/configuring-logging-in-oracle-application-express-listener-2-0-1/
                • 5. Re: REST get request error 400 - Bad Request
                  GeospatialMarty
                  Thanks for trying to reproduce the problem. Ok, I will look at the full stack trace and see what it contains.
                  • 6. Re: REST get request error 400 - Bad Request
                    GeospatialMarty
                    I did a search in the log on the error message (I saw in the browser) and found this:

                    ==== Headers from Results ====
                    Setting Content-Type (Content-type): text/html; charset=utf-8
                    Adding X-Frame-Options: DENY
                    ==== Request Processed ====
                    Processed PL/SQL Gateway request
                    The request path contains illegal characters
                    • 7. Re: REST get request error 400 - Bad Request
                      Colm Divilly
                      I've looked into this further, and managed to reproduce the issue, the problem seems to be specific to standalone mode, I will investigate further, in the meantime you can try using GlassFish or WebLogic to avoid the problem.
                      • 8. Re: REST get request error 400 - Bad Request
                        Colm Divilly
                        Thank you for your problem report, I've filed BUG:16743566 to track this issue, it will be addressed in the next patch release of Listener.

                        This issue only affects standalone mode, so the interim workaround is to use GlassFish or WebLogic instead.
                        • 9. Re: REST get request error 400 - Bad Request
                          GeospatialMarty
                          Thank you. Is there an approximate date for the release of the next patch?