Surendra Sharma

Surendra Sharma

Search This Blog

Monday, October 9, 2017

Curious case of GatherContent module in Sitecore environment


Sitecore-GatherContent Integration
Sitecore-GatherContent Integration

I was trying to integrate GatherContent module in Sitecore.

By the way GatherContent is a collaboration tool where content is drafted, reviewed, analyzed and approved. After approval one can use this data in Sitecore.

It’s pretty simple module. Just download, install and configured it.
But after configuration, when I click on Test Connection- I was expecting either Pass or Fail result, but unfortunately I received error - "The remote server returned an error: (500) Internal Server Error."

I googled this GatherContent error for but was out of luck. So I tried to fix it with no directions. 

I started my investigation from configuration values in GatherContent item at “/sitecore/system/Modules/GatherContent”. Just to make sure, I filled same configuration values in another Sitecore instance and it was working fine. 

Now I was sure that it was my Sitecore project specific instance issue.

Next I checked Sitecore log files and found this error

Exception: System.Net.WebException
Message: The remote server returned an error: (500) Internal Server Error.
Source: System
   at System.Net.HttpWebRequest.GetResponse()
   at GatherContent.Connector.Website.Commands.TestConnection Command.Run(ClientPipelineArgs args)
  
This error gave me next pointer where I decided to decompile the "GatherContent.Connector.Website" DLL using "JetBrains dotPeek" tool.

I checked the code of Run() method in "GatherContent.Connector.Website.Commands.TestConnection" class as mentioned in above error message.

Below is a code for Run() method

Run() Method Code
Run() Method Code


As highlighted "/api/sitecore/mappings/try" is called by Run() method to check the HTTPStatus code. So this call is my next direction to scrutinize.

When I tried to access "http://sitecoreinstance/api/sitecore/mappings/try" from browser, I received error as "The controller for path '/api/sitecore/mappings/try' was not found or does not implement IController."

API Error
API Error


Till this point it was clear that as GatherContent is unable to find "/api/sitecore/mappings/try", that’s why reporting error "The remote server returned an error: (500)".

Next I decided to define all the controllers routing in Sitecore MVC project used by GatherCOntent.

Before that we need to find all controllers referred by GatherContent. Again our helper tool "JetBrains dotPeek" help here. Open DLL "GatherContent.Connector.WebControllers" and check controllers name in "GatherContent.Connector.WebControllers.Controllers" namespace as

GatherContent Controllers
GatherContent Controllers

Specify all these controller's Routing in your Sitecore MVC webproject Global.asax.cs file as


protected void Application_Start(object sender, EventArgs e)

{
    AreaRegistration.RegisterAllAreas();
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
            routes.MapRoute(
    "base",
    "api/sitecore/base/{action}/{id}",
    new { controller = "base", id = UrlParameter.Optional }
    );
            routes.MapRoute(
    "droptree",
    "api/sitecore/droptree/{action}/{id}",
    new { controller = "droptree", id = UrlParameter.Optional }
    );

            routes.MapRoute(
    "import",
    "api/sitecore/import/{action}/{id}",
    new { controller = "import", id = UrlParameter.Optional }
    );

            routes.MapRoute(
    "mappings",
    "api/sitecore/mappings/{action}/{id}",
    new { controller = "mappings", id = UrlParameter.Optional }
    );

            routes.MapRoute(
    "update",
    "api/sitecore/update/{action}/{id}",
    new { controller = "update", id = UrlParameter.Optional }
    );

}

Build and publish this project.

Now try to test GatherContent connection and you should get "Success" message

GatherContent Test Connection Success Message
GatherContent Test Connection Success Message
Greattt, if you are reading this line, it means you are able to solve the issue which was not available on Google and GatherContent helpcenter.

I hope you like this Sitecore GatherContent investigation. Stay tuned for more Sitecore related details.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.

No comments:

Post a Comment