cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

problem with Sending the corret data to the server

Hello


we are trying to develop one simple PowerApps app but we cannot manage to send the data in the right format on our server.

So our server expect a data like this " { "parameters": [ { "param1": 3 , "param2": 2 } ] }"

we tryied with the Table, collection and the closest we achieve is "{ "param1": 3 , "param2": 2 }" , we still miss some piece that need to be send to the server.

How we can achieve that this is send correctly on the server?

-> in this format: { "parameters": [ {"param1": 3 ,"param2": 2 } ] }

Thank you
Cheers

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

The syntax that I specified should work, assuming that the declaration of your custom API function is correct.

 

The fact that it currently accepts simply: { param1: Value(...), param2: Value(...) } without red squiggles / errors indicates that the API declaration itself is incorrect, and it specifies an incorrect type for the function parameter.

 

The formula:

    { parameters: Table( { param1: 1, param2: 2 }) }

 

will produce the following data:

    { parameters: [ { param1: 1, param2: 2 } ] }

 

The API function has to be declared as taking an arg that has that exact type: { parameters: [ { param1: _, param2: _ } ] }

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

Also, what does Intellisense show when you type the name of your function and open a parenthesis?

In looking at your Swagger content, it seems like you are declaring "parameters" to be a required parameter, which cannot be specified in this fashion in the function invocation. Required parameters typically become separate function arguments, so you would need to pass the following to your function:

 

    func(Table({ param1: 1, param2: 2}))

 

Try changing "required" to false, re-deploy your API, and then re-try the invocation I suggested previously:

 

   func({ parameters: Table( . . .) })

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

6 REPLIES 6
Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

The following formula will produce what you want:

 

    { parameters: Table( { param1: 3, param2: 2 } ) }

 

Please avoid string syntax (double quotes) for field names. In the PowerApps Language, field names are identifiers. The only identifiers that require additional decorations are those with blank or non-alphanumeric characters, in which case the single-quote syntax needs to be used. For example, { 'parameters for this query' : { 'a b c' : 2, 'd e f g' : "some text" }

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff
Highlighted
Advocate II
Advocate II

Re: problem with Sending the corret data to the server

Unfortunally is not working....

I get the error: THE FUNCTION HAS SOME INVALID ARGUMENTS

 

error powerapps.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

here is one part of the swagger file:

 

"operationId": "ApiadditionPost",
"produces": [
     "application/json"
 ],
"parameters": [
    {
       "name": "Body",
       "in": "body",
       "required": true,
       "x-is-map": false,
       "schema": {
       "title": "toexportRequest",
       "type": "object",
       "properties": {
                "param1": {
                          "type": "number"
                   },
                 "param2": {
                         "type": "number"
                   }
          }.....................

 

 

 

Basically when we run the server with the debugger, we can see that ther server expects this:
{"parameters":[{"param1":3,"param2":2}] }

 

this shows no error:    .ApiadditionPost( { param1: Value(TextInput1.Text), param2: Value(TextInput2.Text) } )

 

but on the server is then: {"param1":3,"param2":2}

 

so we still miss this part: {"parameters":[ ...... ]}

 

 

We tried everything, Table , Collection, .... everything that came up to our mind, but no success..... Also in the documentation we found nothing similar.

 

 

Do you have some ideas what else we could try?

 

 

Thank you

Cheers

Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

The syntax that I specified should work, assuming that the declaration of your custom API function is correct.

 

The fact that it currently accepts simply: { param1: Value(...), param2: Value(...) } without red squiggles / errors indicates that the API declaration itself is incorrect, and it specifies an incorrect type for the function parameter.

 

The formula:

    { parameters: Table( { param1: 1, param2: 2 }) }

 

will produce the following data:

    { parameters: [ { param1: 1, param2: 2 } ] }

 

The API function has to be declared as taking an arg that has that exact type: { parameters: [ { param1: _, param2: _ } ] }

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

Also, what does Intellisense show when you type the name of your function and open a parenthesis?

In looking at your Swagger content, it seems like you are declaring "parameters" to be a required parameter, which cannot be specified in this fashion in the function invocation. Required parameters typically become separate function arguments, so you would need to pass the following to your function:

 

    func(Table({ param1: 1, param2: 2}))

 

Try changing "required" to false, re-deploy your API, and then re-try the invocation I suggested previously:

 

   func({ parameters: Table( . . .) })

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Advocate II
Advocate II

Re: problem with Sending the corret data to the server

Thank you very much!

 

So I changed the api like you suggested and I can finally retrieve data from the server!

 

I changed required to false, and changed a little bit the parameters and it works!

 

 

I think that should work also with more complicated queries that we have, if not I will write here the problem!

 

 

 

Highlighted
Power Apps
Power Apps

Re: problem with Sending the corret data to the server

Excellent, thanks for reporting back, I am glad to hear that you are unblocked.

Radu Gruian [MSFT] ** PowerApps Staff

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,390)