This tutorial is based on a client project.
The screen shots & notes below accompany this video
Step by step taking you through using Power Automate Desktop to:
- POST OAuth2 Client ID and Client Secret to the Orderspace identity server
- Retrieve an authentication token to be used for calls to the API
- GET (retrieve) orders, in the form of JSON, from the Orderspace API
- Iterate (loop) through the orders JSON
- Iterate (loop) through each order’s line items JSON
- Create a dispatch JSON object
A dispatch is the mechanism for marking an order and each line, fulfilled.
- POST the dispatch JSON back to the API to mark the orders fulfilled
Enjoy the video.
The Annotated Power Automate Flow
The full flow.. just so you can see the actions at a glance.
Action by Action Screen Shots
Note: Actions 07, 11, 12, 14, 15, 17, and 18 seemed clear enough to exclude from the list below. If you have a question about them or anything else, let me know.
Action 01: Invoke web service: POST to receive your authentication token
Submits the client ID and client secret to the authentication server and retrieves the authentication JSON with the access_token key.
Under advanced, select “HTTP authentication” and put your client ID in the user name field and client secret in the password field.
Action 02: Convert OSTokenResponse JSON to custom object
Action 03: Set Variable - the authentication token OSToken
This sets a variable, OSToken, to the authentication token. This variable will be used in the custom header for Authentication: Bearer %OSToken%
Action 04: Invoke web service - GET ordersJSON
This returns the list of orders for processing.
Action 05: Convert JSON to custom object - OrdersObject
Convert the returned orders JSON to a custom object. This allows you to loop through nested items.
Action 06: For Each OrderObject.order
This will loop through each order that was returned in Action 04.
Action 08: For Each CurrentOrder.order_lines
This will loop through each order line object in a given order.
Action 09: Set Variable DispatchLine
This creates a single dispatch line object for inclusion in a complete DispatchOrderJSON.
Action 10: Append DispatchLine (action 09) to DispatchLines
Action 13: Set Variable DispatchOrder
This creates the JSON to be submitted back to the API to clear orders.
Action 16: Invoke web service - POST DispatchOrders JSON to API
Note: per the video, switch all advanced toggles off except clear cookies.
This will post a dispatch to the API, clear the associated order, and reduce inventory.
I hope this was helpful. If so, let me know and consider sharing.