SimonBrown | 2022-04-05 17:04:57 UTC | #1
I really didn't want to join community and fall over at the first hurdle but struggling with data action output contract for my rest service. I am mocking up some methods for a project, so a simple example response like below;
{ "id": 124, "cli": " 447917058256", "firstName": "Simon", "salutation": "Mr", "found": true, "Transactions": [ { "transactionID": "ABCD123456QW", "description": "Transaction 1", "amount": 12.59, "dated": "2022-04-05T16:44:27.4561271+01:00" }, { "transactionID": "ABCD789012QW", "description": "Transaction 2", "amount": 1.89, "dated": "2022-04-05T15:44:27.4562402+01:00" }, { "transactionID": "ABCD770044QW", "description": "Transaction 3", "amount": 1245, "dated": "2022-04-05T14:44:27.4562408+01:00" } ] }
I cannot get a valid response when I try to create Output Contract with a schema (on Simple) I can add fields for the top level items fine, but falling over on the collection. I have tried Object type and Array type for "Transactions" and adding one or more of the collection items
Both yield error from Test option like below (Last attempt set to array type) 11. Validate output against schema: JSON failed schema validation for the following reasons: Schema: # @/properties/Transactions/items. Error location: /Transactions/0. instance type (object) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/Transactions/items. Error location: /Transactions/1. instance type (object) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/Transactions/items. Error location: /Transactions/2. instance type (object) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/Transactions/items. Error location: /Transactions/3. instance type (object) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/Transactions/items. Error location: /Transactions/4. instance type (object) does not match any allowed primitive type (allowed: ["string"])
I have tried call in a flow with no output schema defined and hoped I would see the rawResults as a variable but appears that is not accessible without schema? That may have allowed me to interrogate the raw data in the flow as an option.
I need to get the output contract right in the first instance. I have tried following the documentation but finding the examples devoid of collection information.
I will keep looking but some real world examples and links to pertinent aspects may help if available, I will continue researching but thought I would say "hello" to the community and pose my first problem :slight_smile:
I am new to Genesys but familiar with rest development and other cpaas platforms.
Thanks Simon
SimonBrown | 2022-04-05 20:44:14 UTC | #2
I seemed to have gotten past this now, had to make Transactions level an Array type, then an object type, then my items.
Still learning but not seeing it well in flow, added loop but debug call of flow is difficult to follow and I cannot find any Log files to review?
Assume Action URL cannot be a variable ? Previous applications I have used have an Application level/global level Variables that can be set without need to update actions and republish. Seems to let me changed the Flatten checkbox in testing, which presents differently for my collection schema.
Feels like this will be more of a battle than other CPaaS platforms I have used :frowning:
Jason_Mathison | 2022-04-06 18:17:34 UTC | #3
Hi Simon,
Sorry that you are having a hard time with your first Data Action. Here are some answers to your questions:
I have tried call in a flow with no output schema defined and hoped I would see the rawResults as a variable but appears that is not accessible without schema? That may have allowed me to interrogate the raw data in the flow as an option.
Architect only knows about the fields that are in the output contract, so there is no concept of rawResults that would let you see everything that the data action returns.
I need to get the output contract right in the first instance.
The hope is that you can work through all of the kinks in the test mode of the action prior to publishing. If you find that you have to correct something after publishing the action then you can copy the action, and the copy will be back in a pre-published state. The issue is that once an action has been published a flow or script may be using that action, so a change to the input or output contracts would be catastrophic to those existing consumers.
I have tried following the documentation but finding the examples devoid of collection information.
I will open up an internal ticket to make sure we have some better examples of these scenarios.
I seemed to have gotten past this now, had to make Transactions level an Array type, then an object type, then my items.
Correct, Transactions is an array of objects.
Still learning but not seeing it well in flow, added loop but debug call of flow is difficult to follow and I cannot find any Log files to review?
I believe that the architect team is working on better debugging tools. You might see if there are any ideas around this here: https://purecloud.ideas.aha.io/ideas/ If not, please make one going over your needs. For my architect debugging in the past I would often hook up "Play audio" steps around the data action calls to know if it took an error path or what it returned. I believe that the support organization can get logs for you as well.
Assume Action URL cannot be a variable ?
This is a velocity template, so it is very configurable.
Previous applications I have used have an Application level/global level Variables that can be set without need to update actions and republish.
There are a few ways you could accomplish this. If you are using a custom basic auth then you could stick the variables in your credential and access them in the URL template. Another option that is getting better is using terraform to create/update your actions and flows. You could also pass in variables from your flow, which I think has access to global variables.
Seems to let me changed the Flatten checkbox in testing, which presents differently for my collection schema.
Architect only allows a "flat" input schema, so this checkbox probably needs to be checked for you. Flattening turns arrays of objects into a bunch of top level arrays that architect can process.
Feels like this will be more of a battle than other CPaaS platforms I have used
I'm sorry that this has been difficult. Here are a couple of videos that might be helpful for you: Me going through some examples: https://www.youtube.com/watch?v=o4L6qOqWKdY
Our product manager going through data actions: https://www.youtube.com/watch?v=sNJJDvCkADY
Please let me know of any more rough spots you run into, we want to make this as easy as possible to pickup and use.
--Jason
Anton_Vroon | 2022-04-06 21:26:36 UTC | #4
Data Action is something I also really struggled with when first time using them, and found little information to help me along. Those videos are great, but I never found them when looking around.
Is it possible to create an eLearning module on Genesys Beyond maybe that goes through Data Actions much like in those two videos, but mixing up the video with some text. And maybe also covering velocity macros. And maybe going over some of the helpful online tools that are out there too.
system | 2022-05-07 21:27:28 UTC | #5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 14174