Issue Passing "%" as a String Value via REST

Looking to pass terms code as an API parameter. It works fine if it is just letters and numbers (e.g. N30), but when the terms code has the % (e.g. 2%30, which passes encoded as 2%2530).

Here is an example if you’d like to see what I’m doing.

//// this is hypothetical for demo purposes, my code runs correctly without special characters
var auth = [YourAPIAuthentication];
var url = "https://[yourepicorurl]/Ice.BO.UD20Svc/UD20s";
var parameters = "(Company,Key1,Key2,Key3,Key4,Key5)";
//// In my case one of the Key's is equal to 2%30 or 2%2530
fetch( url + parameters, {
    headers: {
        'accept': 'application/json',
        'Authorization': auth
        },
    method: 'PATCH',
    body: {
        CheckBox01: true,
        RowMod: 'U'
    }
})

I get the following response.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<title>404 - File or directory not found.</title>

<style type="text/css">

<!--

body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}

fieldset{padding:0 15px 10px 15px;} 

h1{font-size:2.4em;margin:0;color:#FFF;}

h2{font-size:1.7em;margin:0;color:#CC0000;} 

h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 

#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;

background-color:#555555;}

#content{margin:0 0 0 2%;position:relative;}

.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}

-->

</style>

</head>

<body>

<div id="header"><h1>Server Error</h1></div>

<div id="content">

 <div class="content-container"><fieldset>

  <h2>404 - File or directory not found.</h2>

  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>

 </fieldset></div>

</div>

</body>

</html>

Has anyone encountered this issue before? Any solution or suggestion is welcomed.
Thanks

Yes, you always want to HTML Encode your data. More info here:

HTML Encoder / Decoder (w3docs.com)

1 Like

The correct URL Encode for % is %25. Epicor’s RESP API Helper automatically encodes it correctly, but I get the error either way.

If you dump the resource (url + parameters) from your code, can you paste it into Postman and test it?

Another useful tool is postman-echo, which lets you post to a service and it echo’s the information from your API call.

Postman Echo | Postman API Network

So hypothetically, if the below was my ( url + parameters )

"https://url.epicorsaas.com/saas/api/v1/Ice.BO.UD20Svc/UD20s(Company,Key1,Key2,2%30,Key4,Key5)"

what should it look like?

You’re getting a 404, so it’s worth checking what you’re sending from different clients to see why the URL doesn’t see the resource you’re looking for. Making sure the URL is what you think it is may shed some light here.

Well here is the thing, if I send N30 instead of 2%30 (there are records for both), the request with N30 works perfectly, but the request with 2%30 returns the 404.
Does this make sense, or do I need to explain it better?

I completely understand what you’re saying.

However, you’re getting a 404, which means the URL is getting mangled somehow. If you dump it and see how it is getting mangled, then you may get some direction toward a resolution.

Gotcha, I’ll play with it in Postman see what happens.
Thanks

1 Like

I can’t get it to work, so I’m just going to change my customization around.
Thanks for your help @Mark_Wonsil

1 Like