No ratings

Rest service returns results as a string instead of json


When generating a Swagger Descriptor for REST-based Services using and the accept header on the request is not text/plain, the response from the Rest API may return the results as a string value instead of the expected Json. This will cause the SmartObject of the rest service to present an error.


Error Code

"Error","SmartObjects","10702","Error","SourceCode.SmartObjects.ServiceBroker [ExecuteSmartObject]","10702 An error occurred in the K2_Management Service Instance. System.Exception: Service: [Service Name]
Service Guid: ef2dd87a-eaf3-42c4-bac1-e8a0312defd3
Severity: Error
Error Message: Encountered a problem calling REST service. (Inner: Error converting value......
InnerException Message: at SourceCode.SmartObjects.Services.K2Management.SmartObjects.Client.ManagementService.ExecuteSmartObjectWithResultCount(Guid SmartObjectGuid, String MethodName, SmartProperty[] InputProperties)","anonymous","","[K2 Server name]:C:\Program Files\K2\Host Server\Bin","867777006","1844a6751cc6472798aaa7b9ad574ed7",""


You need to change the accept header on the request to text/plain. This will return the results of the API as the expected json. 

Additional Information

-  This was discovered in K2 Five (5.3).

- This issue occurred only on Get methods from the swagger that had an array/s.

Related Links

Labels: (1)
Version history
Last update:
‎07-27-2021 05:26 AM
Updated by: