TrimStringProperty is not an allowed Runtime Type


I'm trying to use the TRIMServiceAPI in a .net framework application to create locations via the trimclient Post method...

        public TrimResults CreateLocation(string regno, string honorific, string surname, string givenNames, string birtdate)

                Location newLocation = new Location
                    TypeOfLocation = LocationType.Person,
                    Surname = surname,
                    GivenNames = givenNames,
                    Honorific = honorific,
                    DateOfBirth = (TrimDateTime)DateTime.Parse(birtdate),
                    Notes = TrimModel.UtilityMessage,
                    Initials = GetInitials(givenNames, surname),
                    IdNumber = regno

                newLocation.SetCustomField("RegistrationNumber", regno);

                var response = _trimClient.Post(newLocation);


The post is successful, and I can see the location created in the Content Manager client, including the custom field value for RegistrationNumber,
but it the Post throws an exception before i can read the response...

System.NotSupportedException: TrimStringProperty is not an allowed Runtime Type. Whitelist Type with [Serializable], [RuntimeSerializable], [DataContract] or IRuntimeSerializable, see:
at ServiceStack.Text.Common.JsWriter.AssertAllowedRuntimeType(Type type) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/JsWriter.cs:line 216
at ServiceStack.Text.Common.DeserializeType`1.ExtractType(ReadOnlySpan`1 strType) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeType.cs:line 130
at ServiceStack.Text.Common.DeserializeType`1.ParseAbstractType[T](ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeType.cs:line 148
at ServiceStack.Text.Json.JsonReader`1.Parse(ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Json/JsonReader.Generic.cs:line 111
at ServiceStack.Text.Json.JsonReader`1.Parse(String value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Json/JsonReader.Generic.cs:line 84
at ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/JsonSerializer.cs:line 47
at ServiceStack.Text.JsonExtensions.Get[T](Dictionary`2 map, String key, T defaultValue) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/JsonObject.cs:line 25
at HP.HPTRIM.Service.Client.TrimClient.ToDictionary[T,P](String json)
at HP.HPTRIM.Service.Client.TrimClient.<>c.<FriendlyDictionaries>b__0_8(String val)
at ServiceStack.Text.JsConfig`1.ParseFn(ITypeSerializer serializer, String str) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/JsConfig.cs:line 1001
at ServiceStack.Text.Common.JsReader`1.<>c__4`1.<GetCoreParseStringSpanFn>b__4_0(ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/JsReader.cs:line 48
at ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(ReadOnlySpan`1 strType, TypeConfig typeConfig, EmptyCtorDelegate ctorFn, KeyValuePair`2[] typeAccessors) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeTypeRefJson.cs:line 149
at ServiceStack.Text.Common.DeserializeType`1.StringToTypeContext.DeserializeJson(ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeType.cs:line 58
at ServiceStack.Text.Common.DeserializeListWithElements`2.ParseGenericList(ReadOnlySpan`1 value, Type createListType, ParseStringSpanDelegate parseFn) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeListWithElements.cs:line 194
at ServiceStack.Text.Common.DeserializeList`2.<>c__DisplayClass7_0.<GetParseStringSpanFn>b__0(ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeListWithElements.cs:line 284
at ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(ReadOnlySpan`1 strType, TypeConfig typeConfig, EmptyCtorDelegate ctorFn, KeyValuePair`2[] typeAccessors) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeTypeRefJson.cs:line 149
at ServiceStack.Text.Common.DeserializeType`1.StringToTypeContext.DeserializeJson(ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Common/DeserializeType.cs:line 58
at ServiceStack.Text.Json.JsonReader.<>c__DisplayClass3_0.<GetParseSpanFn>b__0(ReadOnlySpan`1 v) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/Json/JsonReader.Generic.cs:line 20
at ServiceStack.Text.JsonSerializer.DeserializeFromSpan(Type type, ReadOnlySpan`1 value) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/JsonSerializer.cs:line 62
at ServiceStack.Text.DefaultMemory.Deserialize(MemoryStream ms, Boolean fromPool, Type type, DeserializeStringSpanDelegate deserializer) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/DefaultMemory.cs:line 547
at ServiceStack.Text.DefaultMemory.Deserialize(Stream stream, Type type, DeserializeStringSpanDelegate deserializer) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/DefaultMemory.cs:line 523
at ServiceStack.Text.JsonSerializer.DeserializeFromStream[T](Stream stream) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.Text/src/ServiceStack.Text/JsonSerializer.cs:line 210
at ServiceStack.Serialization.JsonDataContractSerializer.DeserializeFromStream[T](Stream stream) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/Serialization/JsonDataContractSerializer.Deserialize.cs:line 60
at ServiceStack.JsonServiceClient.DeserializeFromStream[T](Stream stream) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/JsonServiceClient.cs:line 29
at ServiceStack.ServiceClientBase.GetResponse[TResponse](WebResponse webRes) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/ServiceClientBase.cs:line 2073
at ServiceStack.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/ServiceClientBase.cs:line 1413
at ServiceStack.ServiceClientBase.Post[TResponse](IReturn`1 requestDto) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Client/ServiceClientBase.cs:line 1558
at HP.HPTRIM.Service.Client.TrimClient.Post[TResponse](IReturn`1 request)

When I remove the SetCustomField line of code, then the post works OK without the exception!

Am i doing something wrong? I need the response, to pass on the Uri, and i also need to set the RegistrationNumber field value on create.

I think the error is misleading because, as far as I can tell, TrimStringProperty inherits ITrimProperty which does have the [DataContract] decoration.


  • Ive got this issue as well. Ive been trying to work out how to add the field via the record.fields.add command instead. I managed to get the record.additionalfields.add command to update the additional fields object on the record, but it does not result in a populated field on submit. I think if I can work out how to update the Fields object though (record.fields.add), this might avoid the issue which I suspect is an ommission (bug)

  • What version of TRIM are you using?  I have tried the code below with version 23.4 Hotfix 1.  The file version on the TRIMServiceAPIClient.dll is 10.1.300.756.  There is no exception thrown.

    Location newLocation = new Location
        TypeOfLocation = LocationType.Person,
        Surname = "asdfdsafsdf",
        GivenNames = "asfsdafsdf",
    string abc = "asdfasdfsdf";
    newLocation.SetCustomField("LocationStringField", abc);
    var response = trimClient.Post(newLocation);

    What kind of custom field field is it?  I am using a simple 'string' format custom field.

  • Thank you so much for your interest in this issue!

    My client's Trim Content Manager reports to be version 23.4 build 59 hotfix 1.

    I'm using the Service_API .dll files found in the /DotNetClient directory. These are version

    RegistrationNumber is a string.

    I have copy/pasted your example into my app and it throws the same error.

    I'm just running a simple .net framework console app at the moment, what kind of app are you running?

    Did you have to configure anything to make ServiceStack happy? (i can't figure out how to do this) eg:

  • I am using the same version of TRIM Service API on the web server ( but I realised I am using the dot net client libraries from version 10.1.  I changed my client application to use the version dot net client libraries and sure enough I got the same error that you did. Originally I suspected the error was due to a bug on the server side but this confirms that the error is in the client side libraries and I suspect the serialisation method has changed, using a custom type that the Dot Net runtime is not able to deserialise without some assistance from developers.

    I suggest you raise a bug with OpenText support.  In the meantime you may be able to get away with using an earlier version of the dot net client side libraries (it worked for me!).  If you are going to try this, be sure to test thoroughly for incompatibilities due to different versions.  When developing with the Service API client libraries, ALWAYS use the defined constants for the names properties and special enumeration values so the compiler will check and find errors when these have been renamed and removed.  In recently releases, properties and status values etc are being frequently renamed or removed without warning.  Do not be tempted to use string literals for property names and special values like you may see in some examples - you will be caught out by future versions. 

    If you are developing in C#/dot net and do not have a specific reason to use the Service API then I would recommend using the C# TRIM SDK libraries instead.  They are generally easier to use, more capable and more reliable.

  • Thanks again for you assistance. I'm glad I'm not the only one experiencing this issue! We have raised a support ticket about the issue and are awaiting a response. The ticket will refer to this article too, so there should be lots of information for them to fix the issue.

    Where can I get a hold of the older, working versions of the ServiceAPI libraries?

    I'm actually rewriting an API that previously used the SDK, to decouple the API from their TRIM server and move it to a web server with all their other internal APIs. So I'm kinda stuck with the ServiceAPI.

    Another thought I had... would be to make http calls directly from .net to the ServiceAPI and avoid having to use the broken ServicsAPI libraries, but I can't get their Swagger to open in a browser to see the shape of the data (even after your(?) helpful tip solving the 403 error from another article).

  • You surely can make HTTP calls directly to the Service API but that will be more effort and you'll need to be vigilant about reading release notes for breaking changes in future versions.  I would suggest trying earlier versions of the client libraries first.  They are normally found in the 'DotNetClient' directory of a Service API installation.  If you can get hold of earlier versions of TRIM (e.g. the TRIM 10.1 version that I was using) then you can extract the files to disk and include them in your project.

    When you say you can't use the Swagger interface, what do you mean?  Is it freezing and non responsive? Does the web browser say the page is taking too long and no matter how many times you click on the button to wait longer, it never works?  One of our customers said they just couldn't get the 23.4 version to work and I noticed this problem recently myself.  Something might be broken in the version 23.4 Swagger.

    FYI the TRIM SDK can tunnel through HTTPS just fine and SDK applications can access a remote server that way.  If the customer wants all external connections going through their web server then they can set up a simple redirection/proxy thing from the web server to the workgroup server behind the firewall.  That might be something to think about instead of rewriting SDK applications.

  • Yeah the swagger page appears, then it freezes and goes non-responsive, runs out of memory and dies.

    OMG, can you really use the TRIM SDK to point to a remote TRIM server? Thats exactly what we need! I'll open a new article to discuss the new subject.

    We still have an open support ticket about this error and I will make sure to write here about how that plays out.

    The previous developer built their app on the TRIM server. Including installing (a now old and vulnerable) Visual Studio on the box so they could debug. We assumed they did this because the SDK had to talk to a local install of TRIM. We couldn't find any configuration in their code that we could change to point somewhere else!

  • Do we have a solution for this error?  Could you help advise us on the appropriate course of action?

  • I still have an open ticket with microfocus about the error ... no solution yet.

    With a bit of help, we were able to rebuild the app to remotely call TRIM using the latest SDK, instead of using the ServiceAPI.