What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Send HTTP Request: How to reference the response data with another HTTP request in same automati

Solved

Send HTTP Request: How to reference the response data with another HTTP request in same automation?

Mussty
Excursionist
39 3 16

Hi All,

 

I am trying to create a flow automation when I mark an order fulfilled, I want to change the order status to "Ready to Pickup" in my local delivery management platform, Shipday, and retrieve the tracking link and add it to my order via HTTP Requests. 

 

Shipday allows me to have access to their API and I can do a Get call to retrieve order data. 

 

How do I then use this data back into to another HTTP request with Shipday and with Shopify? (I have created a shopify custom app and have API access to update data, I can successfully update shopify inventory data already via Flow automations)

 

Examples: 

 

Using shopify's order number I am able to make a successful Get order details API call to Shipday and part of that data is their platforms unique orderID and order TrackingLink. (https://docs.shipday.com/reference/retrieve-order-details)

 

To update Shipday that the order is Ready to Pickup when order status is fulfilled in shopify I need to add Shipdays unique OrderID in their API url link when I'm carrying out the Send HTTP Request. (https://docs.shipday.com/reference/order-ready-to-pickup)

 

Mussty_0-1678987527047.png

How do I reference this variable orderID from the previous GET request and place it in the url above where I have marked it {{Shipday.orderID}}? 

 

I then need to create another parallel action to insert the TrackingLink via the API call here: https://shopify.dev/docs/api/admin-rest/2023-01/resources/fulfillment#post-fulfillments-fulfillment-...

 

Again, I am not sure how to reference the data I got from the previous HTTP request and insert "trackingLink" to the request body:

 

{"fulfillment": {"notify_customer": true, "tracking_info": {"number": "1111", "url": "Shipday.TrackingLink", "company": "my-company"}}},
});

 

Any help will be greatly appreciated! 🙂

Accepted Solution (1)

Mussty
Excursionist
39 3 16

This is an accepted solution.

Thanks to @paul_n clarification I used Make.com platform to perform the desired results.

 

For anyone interested I created a shopify flow automation to send the Order number and fulfilment number to make.com via a webhook I created on their platform. I was then able to use the data returned in make.com environment and carry out further https request calls to get the order number from Shipday, then using the trackingLink that I got from the GET request, I was able to update tracking info in shopify.

Mussty_1-1679366778701.png

Send HTTP body content: { "OrderNumber": "{{order.name}}", "FulfillmentID": "{{fulfillment.id | remove: "gid://shopify/Fulfillment/"}}" }

 

Mussty_0-1679366681379.png

 

Further info here: https://community.shopify.com/c/shopify-apis-and-sdks/error-422-tracking-information-update-failed/t...on how I fixed some errors. 

View solution in original post

Replies 11 (11)

paul_n
Shopify Staff
1445 157 334

This is currently not possible as Flow actions don't return data into the environment. Enabling this is very much something we want to do, but it might be awhile before you see it. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Mussty
Excursionist
39 3 16

Hi Paul, thank you for clarifying that. I think that would give Flow super powers when you do!! 😄

Liquify
Shopify Partner
98 1 59

yeah - that would be a nice feature.  hitting this wall today - I think Mechanic can do what you need usually here.

★★★ Need help setting up your Shopify store? Hire me here: https://liquify.design ★★
peterandersen
Shopify Partner
14 1 5

Hi Paul

Does "This is currently not possible as Flow actions don't return data into the environment" also apply to the returned http status code from the "Send HTTP Request" action?


 

paul_n
Shopify Staff
1445 157 334

Yes, but Flow does intercept that status code and will automatically try 5xx type errors. We will be adding fetch capabilities to Run code later this year, allowing you to call almost any API (and return data). 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
kallenconsult
Shopify Partner
65 1 21

Paul,

 

Just out of curiosity, why not leverage the "Send HTTP request" flow block instead of implementing "fetch" in the Run Code?  I mean, is there a security or other reason not to simply add the values to the environment so they're accessible everywhere without needing a Run Code block?

 

Also, speaking of Run Code blocks.  Would love to be able to name them.... Just sayin'.

paul_n
Shopify Staff
1445 157 334

In a lot of http requests you'll need to handle things like paging and authentication that might not be available is a Send HTTP Request in exactly the way you need it. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
kallenconsult
Shopify Partner
65 1 21

When I first read of the HTTP block, I envisioned something like a Postman call, where it handles a lot of it for you.  Now, if you’re looking to make it simple, why not have the Devs trick out the HTTP block?  If you use fetch(), you’ve still got plenty of configuring to do.  As the HTTP block stands now, you CAN configure it by hand, just as you would in a Run Code block (adding header info as necessary), it’s just a pain.

Mussty
Excursionist
39 3 16

This is an accepted solution.

Thanks to @paul_n clarification I used Make.com platform to perform the desired results.

 

For anyone interested I created a shopify flow automation to send the Order number and fulfilment number to make.com via a webhook I created on their platform. I was then able to use the data returned in make.com environment and carry out further https request calls to get the order number from Shipday, then using the trackingLink that I got from the GET request, I was able to update tracking info in shopify.

Mussty_1-1679366778701.png

Send HTTP body content: { "OrderNumber": "{{order.name}}", "FulfillmentID": "{{fulfillment.id | remove: "gid://shopify/Fulfillment/"}}" }

 

Mussty_0-1679366681379.png

 

Further info here: https://community.shopify.com/c/shopify-apis-and-sdks/error-422-tracking-information-update-failed/t...on how I fixed some errors. 

kallenconsult
Shopify Partner
65 1 21

Wow.  Here I was so impressed with Shopify Flow initially.  Now it's just like the rest of Shopify -- lots of potential but not when you get into the weeds.  *sigh*

mttd
Shopify Partner
22 0 13

Thanks for sharing, always good to see someone share the solution that worked for them! Helps others get in to it too.