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

Custom Connector - sending raw body not JSON

Having a problem working around authentication with password flow.

 

I've looked  into this, and am now using no authentication and trying to call the token call manually. 

The problem there is that Powerapps wants to send everything as json, and I cant seem to tell Powerapps that for that request I want just raw text.

 

The system I'm connecting to, for the token call is expecting something like this

grant_type=password&client_id=badf657f-1234-5678-9b07-a123f9fa50cd&username=user&password=password

 

So in short if I pass it as raw body it works. 

How do I get powerapps to allow this? 

Cheers, 
Chris

7 REPLIES 7
Community Support Team
Community Support Team

Re: Custom Connector - sending raw body not JSON

Would it be possible to use concat function within PowerApps to combine the JSON into a string and then pass it through the connector?

Concat and Concatenate functions in PowerApps

 

For custom connector, the request is defined within the Request body, would you please share your OpenAPI file here?

 

Regards,

Michael

 

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

Re: Custom Connector - sending raw body not JSON

Hello,

Some colleauges and I built a custom connector that:

  1. Sends a token request to a token server
  2. Parses the token from JSON
  3. Appends the token and parameters from the PowerApp to a request URL
  4. Sends the request in the format you're looking for
  5. Displays the info back in PowerApps

Let me know and I can share details here.

 

MarkIannucci
Level: Powered On

Re: Custom Connector - sending raw body not JSON

@ericonline , sorry to resurrect this old thread.  It would be fantastic if you can share the details here.

 

Thanks in advance,
Mark

Super User
Super User

Re: Custom Connector - sending raw body not JSON

Hi @MarkIannucci ; sure thing. 

Workflow:

- User enters information into the PowerApp and hits "Submit"

- A Flow kicks off that hits a Token Server and appends the users query information AND the token to a final call for data. 

PowerApp:

- Submit button OnSelect

ClearCollect(
    colFinalDataCall,
    finalDataCall.Run(
        queryParam1.Text,
        queryParam2.Text,
        queryParam3.Text,
        queryParam4.Text)
)

Custom Connector:

- Build this for the DATA CALL (not the token call)

Flow:

image.png

- Trigger: PowerApps

- Action1: HTTP Request TO THE TOKEN SERVER

- Action2: Parse JSON Response

- Action3: The Custom Connector you created earlier

    - Use the Token parsed from Action1

    - image.png

- Action4: Response

    - Use the Body (dynamic content) from the Custom Connector response

 

- Gotchas: IIRC, we had to do some cleanup of the Parsed JSON schema and Body schema sample payload. 
- Been working like a charm for 6-8 months now

Good luck!

MarkIannucci
Level: Powered On

Re: Custom Connector - sending raw body not JSON

@ericonline , Thank you for your response on this, that looks like a pretty sweet solution.  I'm guessing the token in your case is a part of the JSON that you're passing to the connection.  Is that the case?  In mine, I have to pass a bearer token in the authorization header and I've been banging my head against the wall trying to figure out how to variableize it.   
I tried adding it as a custom header in the action:

Annotation 2019-05-29 233604.jpg

And Flow got angry at me.  Going to the detail you get this:

Annotation 2019-05-29 233717.jpg

But unfortunately I haven't been able to pass the token value into the connection...

Super User
Super User

Re: Custom Connector - sending raw body not JSON

Hi @MarkIannucci ,

RE: "...I'm guessing the token in your case is a part of the JSON that you're passing to the connection.": 

- To obtain the token ("Token call"), its a POST request to the token server using an HTTP action in Flow

- To use the token, yes, its passed as a parameter of the GET request to the data server using the Custom Connector in Flow

 

Just to clarify, are you required to get a token as part of each request (because they expire) or do you have a static token?

 

If static: Select `API Key` on the Custom Connector "Security" tab and paste it in.

If dyanamic: You might consider doing away with the Custom Connector all together and only using an HTTP action in Flow. I say this because you can pass Header values (your token obtained from a previous action). 

 

I think this is the only way you can expose Headers.

 

Do you follow?

Super User
Super User

Re: Custom Connector - sending raw body not JSON

Looking a bit closer here... I wonder if you can surface the Auth Header in Flow if you select "API Key" in the Custom Connector "Security" tab. Might try that first. 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 227 members 4,900 guests
Please welcome our newest community members: