" /> Recover parameter from HTTP Request on IRD - Genesys CTI User Forum

Author Topic: Recover parameter from HTTP Request on IRD  (Read 2725 times)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Recover parameter from HTTP Request on IRD
« on: September 06, 2017, 05:44:47 PM »
Advertisement

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]

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: Recover parameter from HTTP Request on IRD
« Reply #1 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].


Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Recover parameter from HTTP Request on IRD
« Reply #2 on: September 06, 2017, 06:22:03 PM »
As usual...you rock Terry :D Thanks!

Offline marmota

  • Jr. Member
  • **
  • Posts: 60
  • Karma: 0
Re: Recover parameter from HTTP Request on IRD
« Reply #3 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.


Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: Recover parameter from HTTP Request on IRD
« Reply #4 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.