"/" Returns 400 Bad Request on BoGet()- Epicor REST Helper

I tried two versions of the call with a part number that had “/” in it. Ex: 1234-1/4
Both of the below options fails. Am I missing something in the way it’s written?

// Option 1 - returns a list of all parts
MultiMap<string, string> parameters = new MultiMap<string, string>();
parameters.Add("PartNum", partNum);
var response = EpicorRest.BoGet("Erp.BO.PartSvc",$"GetById", parameters);

// Options 2 - returns 400 Bad Request
 var response = EpicorRest.BoGet("Erp.BO.PartSvc", $"Parts('{Company ID}','{partNum}')");

Try replacing the slash as %2F. May or may not work, depending on how the web server is set up.

I would think having slashes in part names in general is a bad idea IMHO.

Is there a post endpoint you could use?

It worked thank you. I had just assumed the REST Helper accounted for it but I’ve made the note in my code now.

Agreed, but unfortunately I don’t have a say in part number creation.

Appreciate the response. Thank you again.

I’ve tagged @josecgomez and @jgiese.wci .

We’ll see if they want to make any option or modification to their library.

There may be other problems besides slashes then. I would recommend using one of the built in options C# has for URL encoding a string on the part number before using it.

1 Like

Discussing internally hold please. Concern is will a blanket encode break the rest of “Parts(‘{Company ID}’,‘{partNum}’)”

1 Like

It does indeed freak it out. Will have to self encode the specific variable getting passed in.

As Josh said we can’t encode it for you because only a portion of that parameter should be encoded I would recommend though instead of doing a replace that you use HttpEncoding library as shown

string companyID="MfgSys";
string myCrazyPartNumber="My/Parts/Are/Crazy/Long/And/Have/Slashes/In/Them";

var response = EpicorRest.BoGet("Erp.BO.PartSvc", $"Parts('{companyID}','{System.Web.HttpUtility.UrlEncode(myCrazyPartNumber)}')");
3 Likes