Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

problem with Sending the corret data to the server

(0) ShareShare
ReportReport
Posted on by 99

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

  • rgruian Profile Picture
    rgruian on at
    Re: problem with Sending the corret data to the server

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

  • mob Profile Picture
    mob 99 on at
    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!

     

     

     

  • Verified answer
    rgruian Profile Picture
    rgruian on at
    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( . . .) })

     

     

  • Verified answer
    rgruian Profile Picture
    rgruian on at
    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.

  • mob Profile Picture
    mob 99 on at
    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

  • rgruian Profile Picture
    rgruian on at
    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard