Rest and Part Numbers with Percent Sign

I’m using the Rest API to update our UD05 table and in most cases, it works just fine. The UD05 table is being used to hold our part Compliance information for each Qualified Manufacturer. The Key fields being used are.

Key1 – Part Number
Key2 – Manufacturer (via Manufacturer Number)
Key3 – Manufacturer Part Number
Key4 – Not Used (This causes other issues with Swagger for testing DELETE, but I got around that – I think)
Key5 – Number in Table

The code to POST information seems to be working okay for all part numbers. Deleting information from the table works for all part numbers, except if they have a % character in the Part Number. I don’t like the percentage in the part number, but unfortunately, I have not won that battle yet. I can’t test this out in Swagger (v1) as the UD05-Delete requires information in the Key4 field (which is blank) and 2 single quotes don’t seem to work (‘’) in swagger but do when running it through the Rest call.

For the problem at hand, I believe the issue is with the URL, so I changed the % to %25, but it still fails. I’m not sure what other additional information I can provide, but I take a crack at it,

Sample Json string to Delete.
{
“Company”: “AXIO”,
“Key1”: “100NF-100V-X10%-0603”,
“Key2”: “167”,
“Key3”: “GRM188R72A104KA35D”,
“Key4”: “”,
“Key5”: “1”
}

Request URL
https://epicor.xxxxxxxxxx.com/EpicorTest/api/v1/Ice.BO.UD05Svc/UD05s(AXIO,100NF-100V-X10%-0603,167,GRM188R72A104KA35D,‘’,1)

Tried
https://epicor.xxxxxxxxxx.com/EpicorTest/api/v1/Ice.BO.UD05Svc/UD05s(AXIO,100NF-100V-X10%25-0603,167,GRM188R72A104KA35D,‘’,1)

VBA Code used (condensed version)
pHtml = fn ‘ One of the URLs above
Set httpReq = CreateObject(“Microsoft.XMLHTTP”)
With httpReq
.Open “DELETE”, pHtml, False
.setRequestHeader “Content-Type”, “application/json”
.setRequestHeader “Accept”, “application/json”
.setRequestHeader “Authorization”, "Basic " & Base64Encode(authUser + “:” + authPass)
json = wsRest.Cells(7, 1).Value 'Json string above
.send (json) ‘ Fails here is the part number has a % in it.
End With

I hope I’ve explained this correctly with enough information. I can provide more if needed.

Thanks

Tom

Might need to URL encode the part num string prior to feeding it in. The % sign should change to %25 in your URL string in order to be read as a percent sign.

URL Encode Online | URLEncoder

Or, if you’re doing it programatically, you’ll encode it there first. I’d try it manually just to make sure it’s all good first.

Or the HTML entity might be

%

From Complete list of HTML entities - FreeFormatter.com

The % in the URI is going to be the problem and because of the way that’s passed through I don’t believe any amount of encoding will fix that. I would switch to using the custom method for this over the oData method. In that case you’ll be posting a quoted body string vs putting in the URI

1 Like

Hi Joshua,

Just to follow up on this topic. The Custom method solved my issue.

Thanks for your help.

2 Likes