Problem with Special Characters in Catalina API Query String

Problem with Special Characters in Catalina API Query String

I ran into an issue earlier where I was trying to retrieve a customer using the Catalina Technology API for Dynamics SL. But the problem was that the CustID had special characters in it. In this case, the CustID looked like this: “BB& 1 2

So, there was a prefix of “BB”, then there was an ampersand, and then there were two spaces, then the number 1, two more spaces, then the number 2.

First of all, I had to URL encode the CustID that was getting passed to my API so that the call looked like this:

/api/financial/accountsReceivable/customer/BB%26%20%201%20%202

You can see that & was replaced by %26 and a space was replaced by %20.

Now, that is fine, but then .NET was having problems with the & (even encoded) in that it had an error like this:

A potentially dangerous Request.Path value was detected from the client (&).

This is remedied by looking at the web.config of your ctDynamicsSL application. Search for the keyword: httpRuntime. Once you found that, if you don’t already have an attribute requestPathInvalidCharacters in that key, add it. This is a good default one:

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,%,&amp;,:,\,?" />

Then from that remove the &amp; so that you will allow the & to go in. That way, your final httpRuntime should look similar to this:

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,%,:,\,?" />

As you can see above, I removed &amp;, from the invalid characters. Thus allowing the ampersand to be allowed.

NOTE: If your httpRuntime has other attributes like the .NET version, etc. Leave those alone. Just worry about the requestPathInvalidCharacters attribute and it’s value.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.