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.
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.
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\
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 keywords 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.
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-US" uiCulture="en-US" />
The format for the culture name based on RFC 4646 is languagecode2-country/regioncode2, where languagecode2 is the two-letter language code and country/regioncode2 is the two-letter subculture code. Examples: en-GB for English (United Kingdom) and en-US for English (United States). In cases where a two-letter language code is not available, a three-letter code derived from ISO 639-2 is used. Standards recommend use of lowercase for language codes and capitalization of country codes.
For more information on two letter language codes (languagecode2) refer to ISO 639-1
For more information on two letter country codes (country/regioncode2) refer to ISO 3166-1 alpha-2
There is a possibility to use "auto" as a value for this setting which means that culture to use will depend on browser/base OS language settings.
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.
Examples include ja-JP for Japanese (Japan) and en-US for English (United States). In cases where a two-letter language code is not available, a three-letter code derived from ISO 639-2 is used.