Avaya Support Forums  

Go Back   Avaya Support Forums > Avaya Breeze™ Collaboratory

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-04-2016, 03:29 PM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default REST JSON return to Variables

I am working with a weather web service api and want to turn the JSON return into variables to use in my flow. I am working with Andrew on this. Here is my return:

{'responseCode':200,'responsePayload':'{\'coord\': {\'lon\':-81.76,\'lat\':27.98},\'weather\':[{\'id\':801,\'main\':\'Clouds\',\'description\':\' few clouds\',\'icon\':\'02d\'}],\'base\':\'stations\',\'main\':{\'temp\':305.59,\ 'pressure\':1020,\'humidity\':70,\'temp_min\':303. 15,\'temp_max\':308.15},\'visibility\':16093,\'win d\':{\'speed\':3.6,\'deg\':210},\'clouds\':{\'all\ ':20},\'dt\':1467670298,\'sys\':{\'type\':1,\'id\' :639,\'message\':0.0457,\'country\':\'US\',\'sunri se\':1467628564,\'sunset\':1467678436},\'id\':4153 884,\'name\':\'Eagle Lake\',\'cod\':200}','responsePayloadType':'applic ation/json; charset=utf-8'}

How do i turn this into multiple variables or a variable with sub variables for use in my flow.

Tom
Arrow SI
Reply With Quote
  #2  
Old 07-04-2016, 03:36 PM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default

here is the response without all the added overhead.

{"coord":{"lon":-81.76,"lat":27.98},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":305.49,"pressure ":1020,"humidity":70,"temp_min":303.15,"temp_max": 308.15},"visibility":16093,"wind":{"speed":3.6,"de g":210},"clouds":{"all":20},"dt":1467671719,"sys": {"type":1,"id":639,"message":0.0505,"country":"US" ,"sunrise":1467628564,"sunset":1467678436},"id":41 53884,"name":"Eagle Lake","cod":200}
Reply With Quote
  #3  
Old 07-05-2016, 06:19 AM
ander548 ander548 is offline
Whiz
 
Join Date: Jun 2016
Posts: 37
ander548 has 10 reputation points
Default

Have you tried using the JSON Schema editor in the EDP Administrator Console / Event Catalog? It seems you can build complex JSON like this for your custom events but I'm curious as well whether it will work. The problem I'm having that you may have as well is that it appears the incoming response needs to have a very rigid formatting with your events family, type, version and eventBody form variables where "eventBody" contains the payload. Even if you figure out how to consume the more complicated JSON payload, I think this is going to be a big problem when trying to use 3rd party web services like yours that can't alter their response to match this rigid format. I've asked a question about this on my thread (https://support.avaya.com/forums/showthread.php?t=11740) and suggested it would be more flexible if the callback URL had an ID at the end to identify the event and direct it to the correct workflow so that the incoming response doesn't require special formatting. Good luck!
Reply With Quote
  #4  
Old 07-06-2016, 08:52 AM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default

I haven't tried that but will look at that. My problem is mapping the response to variables.
Reply With Quote
  #5  
Old 07-06-2016, 10:23 AM
vishals vishals is offline
Member
.
 
Join Date: Jul 2016
Posts: 6
vishals has 10 reputation points
Default

There is an option to build the variable to match the return schema. In Output Mapping of the "REST Service Task", you can click on the green "+" symbol to create the same schema.
Reply With Quote
  #6  
Old 07-06-2016, 10:32 AM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default

the schema is in the payload string, that only allows you to duplicate the output schema. I need to take the return that is in the payload and turn it into variables.
Reply With Quote
  #7  
Old 07-06-2016, 10:51 AM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default

I found a generator that will return my schema from the output. But it seems like Breeze doesn't recognize Interger as a json type.

Here is the schema:

{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"coord":{"t ype":"object","properties":{"lon":{"type":"number" },"lat":{"type":"number"}}},"weather":{"type":"arr ay","items":{}},"base":{"type":"string"},"main":{" type":"object","properties":{"temp":{"type":"numbe r"},"pressure":{"type":"integer"},"humidity":{"typ e":"integer"},"temp_min":{"type":"number"},"temp_m ax":{"type":"number"}}},"wind":{"type":"object","p roperties":{"speed":{"type":"number"},"deg":{"type ":"integer"}}},"clouds":{"type":"object","properti es":{"all":{"type":"integer"}}},"dt":{"type":"inte ger"},"sys":{"type":"object","properties":{"type": {"type":"integer"},"id":{"type":"integer"},"messag e":{"type":"number"},"country":{"type":"string"}," sunrise":{"type":"integer"},"sunset":{"type":"inte ger"}}},"id":{"type":"integer"},"name":{"type":"st ring"},"cod":{"type":"integer"}}}

here are the errors i am getting from breeze.

Output Schema: Integer is not a valid JSON data type at 'id'.
Output Schema: Integer is not a valid JSON data type at 'dt'.
Output Schema: Integer is not a valid JSON data type at 'cod'.
Output Schema: Integer is not a valid JSON data type at 'all'.
Output Schema: Integer is not a valid JSON data type at 'deg'.
Output Schema: Integer is not a valid JSON data type at 'id'.
Output Schema: Integer is not a valid JSON data type at 'sunset'.
Output Schema: Integer is not a valid JSON data type at 'sunrise'.
Output Schema: Integer is not a valid JSON data type at 'type'.
Output Schema: Integer is not a valid JSON data type at 'id'.
Output Schema: Integer is not a valid JSON data type at 'humidity'.
Output Schema: Integer is not a valid JSON data type at 'pressure'.
Reply With Quote
  #8  
Old 07-06-2016, 11:39 AM
wilso448 wilso448 is offline
Member
 
Join Date: Jul 2016
Posts: 6
wilso448 has 10 reputation points
Default Solution as of right now.

If I replace Integer with String, everything works. I believe we are good for now.
Reply With Quote
  #9  
Old 07-20-2016, 03:15 PM
joele joele is offline
Member
.
 
Join Date: Jul 2016
Posts: 7
joele has 10 reputation points
Default

If you do run into problems like this in the future, you might look into creating a Dynamic Task Type to invoke your web service. A DTT would be able to take a response in any format whatsoever and then turn it into a form that Engagement Designer would be able to handle.

Andrew, I wanted to address your comment too. The Eventing Framework structure that you mentioned doesn't apply to responses to web service invocations. It only applies to asynchronous events that are being published. I commented on the thread that you referenced: https://support.avaya.com/forums/showthread.php?t=11740.

Please let me know if you have questions on any of this.

Joel
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:04 AM.

This Forum is provided solely for the use and convenience of Avaya customers and partners. Use of the Forum is subject to the Terms and Use and Privacy Statement found at www.avaya.com. No other use is permitted. The Forum including all content posted is “AS IS” and Avaya expressly disclaims all warranties and/or guarantees as to its accuracy, reliability, usefulness, quality or non-infringement of intellectual property. Avaya reserves the right to remove any content posted on the Forum at any time and for whatever reason.

Avaya will not be liable for any content posted on this Forum, including, without limitation, any errors or omissions or for any losses or damages of any kind incurred as a result of use or reliance on any content, regardless of its origin.

You expressly understand and agree that you assume all risks associated with use or reliance on this content.