Genesys CTI User Forum

Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: cavagnaro on September 06, 2017, 05:44:47 PM

Title: Recover parameter from HTTP Request on IRD
Post by: cavagnaro on September 06, 2017, 05:44:47 PM

Hi guys,
I am testing a WS with HTTP request. The return is as follows. Which function should I use to catch the "title" parameter for example?




[code]
13:57:28.665_I_I_007202aa86d49012 [09:05] >>>>>>>>>>>>resume interp(0), func:GetHttpRequestInfoTLS
    _I_I_007202aa86d49012 [09:04] ASSIGN: v1(LOCAL) <- STRING[1,292]: "{
  "userId": 1,
  "id": 1,
  "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
  "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}"
[/code]
Title: Re: Recover parameter from HTTP Request on IRD
Post by: terry on September 06, 2017, 06:05:53 PM
Depends from URS version.
In more or less recent URSes just assign returned value to variable of type LIST (not STRING).
Returned json string automatically will be turned into KVlist then. After that just use KVList functions like
x= KVListGetStringValue[varList, 'title'].

In older URSes probably you will need toe explicitly turn json to kvlist - > varList= KVListFromJSON[v1].

Title: Re: Recover parameter from HTTP Request on IRD
Post by: cavagnaro on September 06, 2017, 06:22:03 PM
As usual...you rock Terry :D Thanks!
Title: Re: Recover parameter from HTTP Request on IRD
Post by: marmota on December 23, 2020, 10:26:15 AM
Hi!

Just for information: we used GetStringKey instead of KVListGetStringValue.
Documentations says GetStringKey should accept String parameter (while KVListGetStringValue  accepts LIST) but both work fine with LIST parameters. I guess GetStringKey is clever enought and transfers LIST to String automatically.
For sure it's better to use KVListGetStringValue with LIST.

Regtarding KVListFromJSON - do you know the difference with KVListFromJSONEx? I didn't get from the documentation.

Title: Re: Recover parameter from HTTP Request on IRD
Post by: terry on December 25, 2020, 06:54:55 AM
KVLists fo not support float values of type float.
If JSON doc happen to have float value then on converting to KVList possible options are
- turn the value into integer, fraction part of value will be lost.
- convert value to string type. Entire value will be preserved, but its type will be string.

KVListFromJSONEx allow to select which option will be used.