cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarkoZ87
Level: Powered On

Parsing JSON

Hello,

 

I'm using a custom connector that connect to my JSON API. API body is in this form:

{
   "cmd":"dllrows",
   "dll":"otcsdf001",
   "function":"tcsdf0001.Get.Contacts.By.Bussines.Partner",
   "params":{
      "BussinesPartner":{
         "type":"string",
         "len":"0",
         "val":"100008848"
      }
   },
   "retval":{
      "type":"long"
   }
}

I have created a button and I would like to call this API OnSelect action. I have created a connection to the data but now I don't know how to send this JSON code to it because it is using nested parameters. So, what is the right form of sending this data to the JSON API?

 

For cmd, dll and function parameter it is simple, but what about the parameters that are under params (type, len, val)?

 

Thank you!

 

Best wishes

Marko

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Parsing JSON

Hi @MarkoZ87 ,

Yeah. If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is just a Text value, you could add a Label control within your app, then set the Text property to your 'ImgJN-kjhna'.GetContactByBussinesPart300(...) formula directly.

 

If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is an array (Table), you could consider add a Data table control or a Gallery control within your app, then set the Items property to your ImgJN-kjhna'.GetContactByBussinesPart300(...) formula.

 

In addition, on your side, you could save your result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returned into a collection or variable using the following formula:

Set(
      ExecutedResult,
      'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

Or

ClearCollect(
                 ExecutedResult,
                 'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

then you could see what type of data included within the returned result within your PowerApps app.

 

If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is an array (Table) with multiple rows, and you want to display the Column1 value of first row of the returned result , please take a try with the following formula:

Set the OnSelect property of the "Button" to following:

Set(
      ExecutedResult,
      'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

Add a Label control, and set the Text property to following:

First(ExecutedResult).Column1

Please take a try with above solution, check if it could help in your scenario.

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
MarkoZ87
Level: Powered On

Re: Parsing JSON

'ImgJN-kjhna'.GetContactByBussinesPart300("b2btes"; "300"; "-1"; {
   cmd:"dllrows";
   dll:"otgbobdll0001";
function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
params:{

From params: on I get lost about the syntax Smiley Happy

Community Support Team
Community Support Team

Re: Parsing JSON

Hi @MarkoZ87 ,

Could you please share a bit more about your custom connector action?

Could you please show more details about the arguments of your 'ImgJN-kjhna'.GetContactByBussinesPart300() function?

Further, could you please share more details about the Action definition within your customer connector?

 

Based on the JSON data format you provided, I found that the BussinesPartner parameter is required to provide a string value.

Please consider modify your formula as below:

 

'ImgJN-kjhna'.GetContactByBussinesPart300(
"b2btes";
"300";
"-1";
{ cmd:"dllrows"; dll:"otgbobdll0001"; function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner"; params:{
"BussinesPartner": "Specific Value provided for this argument"
},
"retval": ...
}
)

 

On your side, you could use Postman tool to test your JSON API firstly, then apply it to your customer connector in PowerApps.

Note: When you use your custom connector action within your app, you could type corresponding arguments based on the formula syntax prompt.

 

More details about creating a custom connector in PowerApps, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/register-custom-api

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MarkoZ87
Level: Powered On

Re: Parsing JSON

Hello,

 

Thank you for your answer. It works now.

 

Only one more question. How can I then display the results from the query? Let's say in a label or in a table if there are more rows returned?

 

Thank you!

 

Best wishes,

Marko

 

 

Community Support Team
Community Support Team

Re: Parsing JSON

Hi @MarkoZ87 ,

Yeah. If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is just a Text value, you could add a Label control within your app, then set the Text property to your 'ImgJN-kjhna'.GetContactByBussinesPart300(...) formula directly.

 

If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is an array (Table), you could consider add a Data table control or a Gallery control within your app, then set the Items property to your ImgJN-kjhna'.GetContactByBussinesPart300(...) formula.

 

In addition, on your side, you could save your result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returned into a collection or variable using the following formula:

Set(
      ExecutedResult,
      'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

Or

ClearCollect(
                 ExecutedResult,
                 'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

then you could see what type of data included within the returned result within your PowerApps app.

 

If the result your 'ImgJN-kjhna'.GetContactByBussinesPart300() function returns is an array (Table) with multiple rows, and you want to display the Column1 value of first row of the returned result , please take a try with the following formula:

Set the OnSelect property of the "Button" to following:

Set(
      ExecutedResult,
      'ImgJN-kjhna'.GetContactByBussinesPart300(
                                          "b2btes"; 
                                          "300"; 
                                          "-1"; 
                                          {
                                             cmd:"dllrows";
                                             dll:"otgbobdll0001";
                                             function:"tgbobdll0001.Get.Contacts.By.Bussines.Partner";
                                             params:{
                                                     "BussinesPartner": "Specific Value provided for this argument"
                                             },
                                             "retval": ...
                                          }
)
)

Add a Label control, and set the Text property to following:

First(ExecutedResult).Column1

Please take a try with above solution, check if it could help in your scenario.

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Support Team
Community Support Team

Re: Parsing JSON

Hi @MarkoZ87 ,

Have you solved your problem?

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved for other users in this forum.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.