This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Issue

After selecting SmartObjects to be exposed via the SmartObject OData API, they do not show in the OData feed, although they get listed under SmartObjects in the SmartObject OData API section of the K2 Management site. No error message is presented when you add or remove them from this list.

Symptoms

After selecting SmartObjects to be exposed via the SmartObject OData API and clicking apply, the added SmartObjects do not show up in the OData feed.

Troubleshooting Steps

It is possible to enable additional diagnostic logging to troubleshoot/verify the root cause of this issue. To enable logging in [Install directory]\WebServices\API\SmartObjectService.OData edit the web.config and comment out the following part under <system.diagnostics>:

<remove name="DevLogTraceListener" />



Right above the commented line, add the following new line:

<add name="TestTracer" type="System.Diagnostics.TextWriterTraceListener, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="C:\Program Files (x86)\K2 blackpearl\WebServices\API\Logs\Test2.log" traceOutputOptions="Timestamp"/>


Save the web.config file - no IIS reset is required. Providing the folder path in the line above is valid for your system (if not adjust as necessary). You will see two log files in the following location:

C:\Program Files (x86)\K2 blackpearl\WebServices\API\Logs\

File names:
SmartObjectServiceTrace.log
Test2.log

You may see the following error message logged in the diagnostics logs in this scenario:

"w3wp.exe Warning: 0 : Unexpected error while refreshing in-memory cache.
System.TypeInitializationException: The type initializer for 'SmartObjectService.Web.Extensions.StringExtensions' threw an exception. ---> System.NotImplementedException: The culture 'German (Germany)' is not supported. Pluralization is currently only supported for the English language.
at System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(CultureInfo culture)"

The key words in this error message are: "The culture 'German (Germany)' is not supported. Pluralization is currently only supported for the English language."

This error message is related to region and language settings. When you click Apply, OData API tries to pluralize the name of the SmartObject to create the route name and publish the $metadata.
For example: if you have "Customer" as a SmartObject name, the OData API will publish "/Customers". This issue is caused by the fact that the culture settings (Regions (intl.cpl) > Format > Format) is not set to English for the K2 Service and/or the K2 Application Pool account, because of this the OData API fails to pluralize, and consequently also fails to create the route for the SmartObject (thus fails to publish the SmartObject).

To resolve this, it is necessary to append [K2dir]\WebServices\API\SmartObjectService.ODataWeb.config with the following setting:

<globalization culture="en-En" uiCulture="en-En" />


This has to be placed under <system.web>
Next, perform an IIS reset. Usually just editing the web.config is sufficient because a config change restarts the web app but in this case PluralizationService gets created as a read-only static object, so you would have to restart the service to get it set with the new culture.

Your other option to resolve this can be to set both the K2 Service and K2 Application Pool accounts to use English format settings.