Forum Stats

  • 3,783,301 Users
  • 2,254,754 Discussions
  • 7,880,358 Comments

Discussions

Rest Web Services Special Characters - % $

DLopez
DLopez Member Posts: 278
edited Feb 17, 2017 7:01AM in JDeveloper and ADF

Hi,

Using JDev 12c (12.2.1.0.0)

I have created some Rest Web Services, POST, DELETE and GET, and recently I have been trying to fix the following issue with no luck.

In a GET method I send a String that contains this character %, like %2521 and when I receive it in my Service I only obtain %21.

Basically my string won't arrive like I send it. The only way so far I was able to get the string the way I have send it was turning my GET method into a POST.

Is there any other way that this can be done without using POST methods?

Thanks

Daniel

Tagged:

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,798 Red Diamond
    edited Feb 15, 2017 3:20PM

    From https://tools.ietf.org/html/rfc3986#page-11

    Because the percent ("%") character serves as the indicator for  percent-encoded octets, it must be percent-encoded as "%25" for that  octet to be used as data within a URI.

    Which means in your case that hte %25 is decoded as % and the 21 remains as 21 giving you %21. To pass %2521 you need tp '%' encode the % as %25, to encode '%2512' write '%252521'.

    Timo

    DLopez
  • SanjeevChauhan
    SanjeevChauhan Member Posts: 1,554 Gold Trophy
    edited Feb 15, 2017 11:13PM

    As you are sending encoded url your %25 is decoded back and became %.

    You can very well send %252521 this will make decoded value as %2521.

    Generally I would suggest to use some api to url encoding. That way you just need to use value %2521 and ask api to encode it and then call REST service. Api will make encoded value as %252521 and when server side it gets decoded it will become %2521.

    If you are using javascript to invoke REST then you can use <span class="pln" style="color: #303336;">encodeURIComponent(myUrl) api to encode url</span>

    If you are using java as client to invoke REST then you can use <span class="typ" style="color: #2b91af;">URLEncoder</span><span class="pun" style="color: #303336;">.</span><span class="pln" style="color: #303336;">encode api</span>

    Thanks

    Sanjeev.

    DLopez
  • DLopez
    DLopez Member Posts: 278
    edited Feb 17, 2017 7:01AM

    Thank you Sanjeev and Timo for your replies.

    I'm using Web Service Data Control (SOAP / REST) as my client to create my Data Control, but in the options I can't find where to configure to Encode that String.

    Do you have any idea on how to do it?

    Thanks.

This discussion has been closed.