cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

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
Syndicate_Admin
Administrator
Administrator

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

Syndicate_Admin
Administrator
Administrator

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
murshed
Microsoft
Microsoft

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"}});
murshed
Microsoft
Microsoft

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"

Syndicate_Admin
Administrator
Administrator

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.  

Syndicate_Admin
Administrator
Administrator

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})'

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Users online (2,898)