Tip of the Week #103 | The Forward Slash Is Buggin’ the OData! | Print Software Blog

Tip of the Week #103 – The Forward Slash Is Buggin’ the OData!

Developer Peter Tijsma has a tip this week to fix a tricky little parameter issue in Excel.

Problem: Microsoft Dynamics NAV OData Feeds issue when using a Company Name in NAV that contains a forward slash “/”

When your company name contains a forward slash (which is commonly used in Denmark, like NovaVision A/S) – OData suddenly refuses to work with Excel.

The message you’ll receive will be something like “The remote server returned an error: (400) Bad Request,” even though you’re absolutely sure the supplied address is correct (you copied it from the NAV Web Services Page, so it should be right… right?)

When you use a browser and point it to this link, it all seems to be right, so what’s the issue here?

We’ve addressed this with Microsoft and the response was:

Problem is that excel is trying to unescape the slashes before sending the Uri to NAV

In other words: Excel is reverting the supplied Uri to: https://[serveraddress]/PrintVis-Internal-O365/OData/Company(‘NovaVision Software a/s’)/Top10Customers and is sending that to NAV.

The problem now is that the forward slash in the company name is seen as a regular slash in the address Uri and not anymore as a parameter.

Microsoft is now making a bug-case out of this – so probably in a next Cumulative Update, this will be fixed.

But no fear! Until then, there’s a workaround supplied by Microsoft. (Not the nicest one, but it’ll do the trick).

You will have to create a configuration file for excel.exe.config, located in the same directory of excel.exe with this content:

<?xml version=”1.0″ encoding=”utf-8″ ?>

<configuration>

<uri>

<schemeSettings>

<add name=”http” genericUriParserOptions=”DontUnescapePathDotsAndSlashes” />

<add name=”https” genericUriParserOptions=”DontUnescapePathDotsAndSlashes” />

</schemeSettings>

</uri>

</configuration>

This will make sure that Excel doesn’t unescape the slash in the company name – and it’ll suddenly accept the OData feed:

Enjoy!

Thank you Peter!

URL vs. URI: https://blog.udemy.com/url-vs-uri/

URL Encoding: http://www.albionresearch.com/misc/urlencode.php