cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Entilzha
Frequent Visitor

How to call when Header entry and Body parameter have same name

How do you differentiate between Header and Body values when making a POST request in a PowerApp to a Custom Connector?  This is especially tough since I have to specify BOTH the header and body values in the call to the Action (can only specify 0 or 1 parameters).  My problem is I have a two different “Host” values I need to specify.  One for the Header and the other in the Body.  I need some guidance on how to keep them separate in this call to my Custom Connector.  (connector images below)

 

'PartnerConfig-UT'.Create({'Host': "api.mycloud.com", 'body': {'PartnerId': "pid", 'PartnerName': "pname", 'Host': "phost"}}); 

 

Here’s what the Definition of my “Request” Action looks like in the Custom Connector specification: 

 

Entilzha_0-1628005360685.png

 

 

And the “body” Parameter definition: 

Entilzha_1-1628005360687.png

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Entilzha
Frequent Visitor

I was able to convince the team responsible for the API to change the endpoint name from "Host" to "CallbackHost".  That resolved the name conflict and now everything is working.  I still believe there must be a simple way to declare Body values unique from Header values with the same name.  

View solution in original post

Entilzha
Frequent Visitor

I have a better answer that I will include here for posterity.  There are four different places in an HTTP request that may need to be populated with variable data: 1) URL Path, 2) URL Query, 3) Request Header, 4) Request Body.  I do a review of how to specify and populate each one. Unfortunately many of these values are jammed into the same  object.  Fortunately the Power tools provide a way to specify each one differently.  Even more fortunately there is an "intellisense" capability inside the PowerApp editor that will tell you what it is expecting to see.  That helps a lot in fixing problems where the feedback is similar to "expected text but got an object".  To start the intellisense specify the ConcurConnector and the Action.  The intellisense will appear as soon as you enter the left paren for the Action.  Just follow the guidance they provide.  Using my example above, the intellisense pops up as soon as you enter the left paren:  'PartnerConfig-UT'.Create(

1) URL Path - this is the easy one.  When you want to specify a value in a URL path you surround the field with curly brackets.  The only way to enter this is when you "Import from sample" in the Request.  Here is an example URL that will automatically create a "Path" variable for the "url" field:  'https://graph.microsoft.com/{url}'.  I have only done one Path variable but I believe you can do more.

2) URL Query - this is the fun one.  Similar to the Path variable is the Query variable specifier.  You would also define this when you "Import from sample" and provide the query variables in the url sample.  The main difference is each of the query variable names need to be preceded with a dollar($) sign.  e.g., '{url}?$company=cname&$cfo=todd'  will result in two new query variables called '$company' and '$cfo'.  I may be wrong about requiring the dollar sign but I have seen it in several examples.  Please post here if you know otherwise.

 

3) Request Header - Does someone have any tips for headers?  Please include in your own comments below if you know the answer.

 

4) Request Body - These values are also automatically populated from your sample.  Precede their value with their name and a colon(:). e.g., 'PartnerId:txtPartnerId.Text'

 

Here is a more complete example that is close to what I had to use.  The first parameter is my Path variable while the second is an object with the Body variables.  Tip: you do not need to specify any variables where you are happy with the default value that you assigned to it.

'PEB-PartnerConfig-UT'.Update(Gallery1.Selected.id, {PartnerId:txt_PartnerId.Text,PartnerName:txt_PartnerName.Text,CallbackHost:txt_Host.Text})'

View solution in original post

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

You can probably use display name property to identify separately.

If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION ☑️. If you find this reply helpful, please consider giving it a LIKE 👍.

Would you please elaborate what you mean by "use display name property"?  How would that apply to this invocation in my PowerApp to the Custom Connector?

'PartnerConfig-UT'.Create({'Host': "api.mycloud.com", 'body': {'PartnerId': "pid", 'PartnerName': "pname", 'Host': "phost"}});
Syndicate_Admin
Administrator
Administrator

Can you call the body parameter as `basePath` or something else instead of host, since it's clearly not host? You will see the display name property if you click edit for the parameters. Look at this swagger for an example: https://github.com/microsoft/PowerPlatformConnectors/blob/dev/certified-connectors/AzureAD/apiDefini...

If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION ☑️. If you find this reply helpful, please consider giving it a LIKE 👍.

What do you mean "click edit for the parameters"?  The only interpretation I have is to use the "Swagger Editor" in the CustomConnector "Definition" page.  But "displayName" was not in there.  I can click "Edit" for the "Host" parameter in the definition of the Body but that doesn't show anything named "displayName"

Entilzha
Frequent Visitor

I was able to convince the team responsible for the API to change the endpoint name from "Host" to "CallbackHost".  That resolved the name conflict and now everything is working.  I still believe there must be a simple way to declare Body values unique from Header values with the same name.  

View solution in original post

Entilzha
Frequent Visitor

I have a better answer that I will include here for posterity.  There are four different places in an HTTP request that may need to be populated with variable data: 1) URL Path, 2) URL Query, 3) Request Header, 4) Request Body.  I do a review of how to specify and populate each one. Unfortunately many of these values are jammed into the same  object.  Fortunately the Power tools provide a way to specify each one differently.  Even more fortunately there is an "intellisense" capability inside the PowerApp editor that will tell you what it is expecting to see.  That helps a lot in fixing problems where the feedback is similar to "expected text but got an object".  To start the intellisense specify the ConcurConnector and the Action.  The intellisense will appear as soon as you enter the left paren for the Action.  Just follow the guidance they provide.  Using my example above, the intellisense pops up as soon as you enter the left paren:  'PartnerConfig-UT'.Create(

1) URL Path - this is the easy one.  When you want to specify a value in a URL path you surround the field with curly brackets.  The only way to enter this is when you "Import from sample" in the Request.  Here is an example URL that will automatically create a "Path" variable for the "url" field:  'https://graph.microsoft.com/{url}'.  I have only done one Path variable but I believe you can do more.

2) URL Query - this is the fun one.  Similar to the Path variable is the Query variable specifier.  You would also define this when you "Import from sample" and provide the query variables in the url sample.  The main difference is each of the query variable names need to be preceded with a dollar($) sign.  e.g., '{url}?$company=cname&$cfo=todd'  will result in two new query variables called '$company' and '$cfo'.  I may be wrong about requiring the dollar sign but I have seen it in several examples.  Please post here if you know otherwise.

 

3) Request Header - Does someone have any tips for headers?  Please include in your own comments below if you know the answer.

 

4) Request Body - These values are also automatically populated from your sample.  Precede their value with their name and a colon(:). e.g., 'PartnerId:txtPartnerId.Text'

 

Here is a more complete example that is close to what I had to use.  The first parameter is my Path variable while the second is an object with the Body variables.  Tip: you do not need to specify any variables where you are happy with the default value that you assigned to it.

'PEB-PartnerConfig-UT'.Update(Gallery1.Selected.id, {PartnerId:txt_PartnerId.Text,PartnerName:txt_PartnerName.Text,CallbackHost:txt_Host.Text})'

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,348)