Need Help - Simple example of SmartObject from a REST Service that returns a List


Anyone got any simple examples of how to create a Smart Object with a List method that returns an array of objects from a web service call?

 

 

After creating a service instance from the REST Service type I have gone into the SmartObjects testing tool and generated the smart object.

 

In the Workflow I created two steps. One was a reference to obtain the array, the 2nd was another reference to use the pass the array to a deserialise type array method. 

 

I tried to loop through the 2nd reference but it does not look right.

 

 

Here is the reference that should create my list:

11352i3E939996E17CBFFE.png

 

 

Getting data back from a webservice that isn't a list is fine. Just having trouble with lists...!


5 replies

Userlevel 6
Badge +16

Hi,


 


Are you trying to do this in the workflow or at the Smartforms level? Maybe, you can try out the out-of-the box Workflow REST in K2 Five.


https://help.k2.com/onlinehelp/k2five/userguide/current/default.htm#K2-Management-Site/Integration/Workflow-REST-API.htm


 


1. Enable Workflow API.


2. Downlnoad the Swagger file


 



 


3. Register the REST service instance. The service instance is setup to Static authentication but you can use other authentication types.



 


4. Create Task and Task Lite SmartObjects.



 


5. Task SmartObject > Get Tasks method



 


6. Copy Tasks (TaskLite[]) and use it in the Task Lite SmartObject to deserialze the array.



 


 


 


 


 

Many thanks. I managed to create my own SmartObjects from a REST Service using your suggestion :)

 

However when I loop through them in a Workflow I do not get any data from the item reference (?!).

 

I have one more final piece of the piece of the puzzle. I have two separate methods to return a list:

  • 1st method calls an underlying REST Get method to return a serialized array (in a memo field)
  • 2nd method calls the deserialized typed array method to convert the string (from the first method) to a list

When I test this in the SmartObject testing tool everything works fine. I call two methods and a get a list back.

 

When I try to implement this in a workflow and loop through the items in the list - it doesn't work! It loops through the correct number of times but I cannot obtain values from the item in the foreach loop.

 

When I try each getting values for item in the loop it returns the text 'System.String[]'.

 

 

Screenshots below:

 

 

 

Badge +5
Hi, any update on this thread? Even I am getting 'System.String[]' while looping through deserialized list. Is there any specific way I need to follow to get proper data from restful smo. I am trying to insert the list received through rest smo into SQL database.
Thank you
Badge +9

Hi Kathija


 


If u are using K2 5.1 and you are getting the 'System.String[]'. this a a bug and  this issue was fixed in K2 5.1 Fix Pack 7


Please visit the link attached about this issue: https://help.k2.com/kb002533


 


Regards


Elvis

Badge +1

Hi,

 

I'm having the same problem in version K2 Five 5.6. I would be happy if anyone can help me solve the problem.

 

Thanks.

Reply