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

Postman Pre-Request Script?

I'm trying to build a custom connector from a Postman collection that has a pre-request script in it.

 

That script creates one of the variables in the header that is needed for authentication. It doesn't look like you can run any Java scripts in flow. Am I missing any obvious solutions?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Impactful Individual
Impactful Individual

Re: Postman Pre-Request Script?

I found this thread looking for answers to the same challenge.

 

If you can't use Logic Apps (e.g. you need a PowerApps trigger, an approval or a Flow button for mobile etc) you can create an HTTP triggered Node.js Azure function to replicate the functionality of the pre-req script.

 

 

 

You can pretty much copy and paste the code from your Postman pre-req script with minor changes, such as substituting pm.environment.get('variable') with req.body.variable and pm.environment.set("variablename", variablevalue) with elements in the response body, e.g.

 

context.res ={ headers: {'content-type':'application/json'},

body: {'variablename':variablevalue}}

 

You can pass in the parameters in an HTTP POST body, process them with JS code copied from your Postman script, e.g. HMAC encryption, and pass the output back out in the response to use in your auth header.

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: Postman Pre-Request Script?

Hello @Chauc3r 

 

You cannot run JavaScript in Power Automate at this time.

 

Logic Apps you can, by the use of Integration Accounts:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-add-run-inline-code#:~:text=If%20you%20...





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips, tricks, and guides
FlowAltDelete




Highlighted
Impactful Individual
Impactful Individual

Re: Postman Pre-Request Script?

I found this thread looking for answers to the same challenge.

 

If you can't use Logic Apps (e.g. you need a PowerApps trigger, an approval or a Flow button for mobile etc) you can create an HTTP triggered Node.js Azure function to replicate the functionality of the pre-req script.

 

 

 

You can pretty much copy and paste the code from your Postman pre-req script with minor changes, such as substituting pm.environment.get('variable') with req.body.variable and pm.environment.set("variablename", variablevalue) with elements in the response body, e.g.

 

context.res ={ headers: {'content-type':'application/json'},

body: {'variablename':variablevalue}}

 

You can pass in the parameters in an HTTP POST body, process them with JS code copied from your Postman script, e.g. HMAC encryption, and pass the output back out in the response to use in your auth header.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,752)