After years of refusing myself to blog about my job, I finally decided to share some things that may be useful to others, and of course what better way to start than talking about my platform of choice and a problem that may take days to troubleshoot.
So, let’s get to the point. For some reason, despite all your efforts, your goal of making a successful sync from AX into Commerce seems far, far away.
You have already installed Sitecore, of course. You also have installed and configured your local instance of Sitecore Commerce. You have installed the Commerce Connector, and all of the necessary packages, merged all config files, and finally downloaded, opened and compiled the Routing Framework SDK flawlessly.
Then you run the console app – and nothing. Nothing but exceptions, that is.
Then you go and check Hao Liu’s excellent post about this topic, and then the one about the changes in Update-1. You realize that you should have checked Hao Liu’s blog before, but hey, no harm done, you check that all is ok, and follow his advice.
Still nothing but exceptions.
Don’t despair, there are still some things you can check.
-“Help! the console app throws a gross exception about a task that wasn’t completed, or something”
-Ok. First thing to check is that you have access to the Retail database and to the Dynamics Realtime service. Make sure your dev machine can connect to the SQL server and the database, and that the user that you specified (or the logged-in user, in case of a trusted connection) have the necessary permissions there. Also, check the channel ID of course.
-“I did! but I still see the same task something something exception. But now it says ‘Not Found’ too!”
-Ok, sit down, grab a cup of coffee and relax a bit. When you regain your coolness, go and open IIS manager. Make sure that you have a binding for accessing your Sitecore instance via https. It’s absolutely necessary, since the sync process depend on this. Also, double-check that you point to that binding in the console app’s config file. (BTW, it doesn’t hurt to check the username/password combination either).
-“OMG – Something happened. I can see that the route starts, but it blows up after a couple of seconds and the sync process still does nothing but explode with those weird exceptions”
-First of all, no exception is weird (although I could be proven wrong if for some reason the next .Net framework version comes with a WeirdException class). Second, chances are that you are seeing references to the SitecoreWebApi methods in the stack trace shown. If so, a little jewel that took me a long time to find may be the culprit.
Go and check your web config – search and find this tag (if your site runs on IIS):
Or this tag (if your site runs on IIS Express):
Make sure that you have PUT, DELETE and PATCH as accepted verbs for the handler. For instance:
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type=...... />
-“It works now! Is this magic? Are you some kind of wizard?”
Well, it is, but not that kind of magic. And yes, I am, just not that kind of wizard.
Turns out that Sitecore Web Api (or, in newer versions, Sitecore Client Services , which is a layer on top of it) require these verbs (BTW, not sure about the DELETE one, but in a dev machine I assume it’s safe to add it) to perform edit/update operations on the content tree, and the processors in charge of performing the sync tasks need to change fields like the last run date and others.
With the setting you just changed, you told IIS that there are handlers that do not have an extension (i.e. Sitecore Web Api stuff) that will handle such verbs. Before you changed this, IIS was just not letting the requests go through. Therefore, you got a Not Found (i.e. a 404 error) message somewhere.
There you go, some reading material and hopefully one or two things that could save you some troubleshooting time.
See you later!