How do I get this into a variable/output

Status
Not open for further replies.

greychain

Gold Partner
Advanced Certified
Joined
Jul 13, 2018
Messages
779
Reaction score
122
I am calling an API and am getting this result.

{"res.partner": [1]} if there is one result that matches my search or
{"res.partner": [8,1]} if there were two matches to my search, the 8 and 1 are the company ID. How do I get the first value into a variable/output?

Seems I've asked a similar question before.
 
Last edited:
I am calling an API and am getting this result.

{"res.partner": [1]} if there is one result that matches my search or
{"res.partner": [8,1]} if there were two matches to my search, the 8 and 1 are the company ID. How do I get the first value into a variable/output?

Seems I've asked a similar question before.
You can't. 3CX cannot use an unindexed array.
 
  • Like
Reactions: edossantos
I have tested the JSON and it appears to be a valid response, will raising this as a support request help?
 
I have tested the JSON and it appears to be a valid response, will raising this as a support request help?
No, this is just not supported. If you have control over the CRM, then you will need to change the response format to avoid this kind of arrays. If you can't do this, then you will need a proxy between 3CX and the CRM, to perform a "translation".
 
  • Like
Reactions: Evolute IT
How would I need to change this output to match what 3CX will accept? I have the CRM restapi code and am looking at modifying the output to match 3CX requirements.

Can you give an example of how this result would look like to be accepted by 3CX, thanks.

Could I use a CFD to process the phone lookup request?
 
How would I need to change this output to match what 3CX will accept? I have the CRM restapi code and am looking at modifying the output to match 3CX requirements.

Can you give an example of how this result would look like to be accepted by 3CX, thanks.
Anything that is not an array. So for example, instead of:
JSON:
{
   "res.partner":[
      8,
      1
   ]
}

You could use:
JSON:
{
   "res.partner": {
       "first": 8,
       "second": 1
   }
}
 
Could I use a CFD to process the phone lookup request?
From a CFD app you can invoke your API, parse the response as you need, and attach the data to the call. In this case you don't have limitations, as you can use a C# script to parse the JSON in the way you want. But this is just to do the contact lookup and then transfer the call to the next recipient. You will not be able to implement call journaling from a CFD app.
 
Status
Not open for further replies.