Library with Rest-API Call doesnt work in all processes

I build a Library that does an API Call, deserializes the answer and returns a specific value.

When using it in one automation - i dont have any issues with it.
when using it with another automation i get this exception:

RemoteException wrapping System.Runtime.Serialization.InvalidDataContractException: Type 'System.Collections.IEnumerable' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types. 
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.Activities.WorkflowApplication.IdleEventHandler.OnStage2Complete(IAsyncResult lastResult, WorkflowApplication instance, Boolean isStillSync)
   at System.Activities.WorkflowApplication.EventFrame(IAsyncResult result)

Does anyone have an idea how i could fix this?

Hi @hannes.goldfuss,

The exception message you received indicates that there is an issue with the serialization of the data returned by the API call in the automation where the exception occurred. Specifically, the exception message suggests that the data returned by the API includes a type that cannot be serialized, specifically the type System.Collections.IEnumerable.

To resolve this issue, you will need to modify your library to ensure that any data returned by the API can be serialized properly. Here are a few steps you can take to do so:

  1. Identify the source of the issue: Take a closer look at the data returned by the API in the automation where the exception occurs. Specifically, look for any instances of the System.Collections.IEnumerable type that may be causing the issue.
  2. Mark types with the [DataContract] attribute: If you find that the data returned by the API includes types that are not marked with the [DataContract] attribute, you will need to add this attribute to those types to enable them to be serialized properly.
  3. Mark members with the [DataMember] attribute: Similarly, you may need to mark specific members of these types with the [DataMember] attribute to ensure that they are serialized properly.
  4. Check for other unsupported types: In addition to the System.Collections.IEnumerable type, there may be other types returned by the API that cannot be serialized properly. Be sure to review the Microsoft .NET Framework documentation to identify any other unsupported types and ensure that they are handled properly in your library.
  5. Test your changes: Once you have made these changes to your library, be sure to test it thoroughly to ensure that it is working as expected and that the exception no longer occurs in your automation.