Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How can I make a request (POST/GET) to Shopify App from an external server?

How can I make a request (POST/GET) to Shopify App from an external server?

rousnay
Shopify Partner
5 0 1

Hi, I am new to Shopify App development, but I have to build a fairly complex app on top of NodeJS and ReactJS. I got stuck with receiving webhook notifications from an external server. I have developed a POST API endpoint in my app to work as a webhook receiver. But the problem is that I need help accessing the API's endpoint (built in the app) from outside the Shopify store.

API endpoint of my app is:
https://app_url/api/notification_reciever

I also have set up an App proxy like this:
https://app_url/proxy_route/api/notification_reciever

And I can access the endpoint from the theme:
https://store_url/api/notification_reciever

How can I access the API endpoint from the outside world with the POST/GET method? I am eagerly waiting for help; any tips are valuable to me in this regard.

Thanks in advance 🙂

Replies 4 (4)

Liam
Community Manager
3108 344 894

Hi Rousnay! 

 

Great to hear you're working on a Shopify app project! Where is the app currently hosted? If you want to be able to make API calls you should ensure that your app's API endpoint is hosted on a publicly accessible server. When you make a post request to https://app_url/api/notification_reciever what are you seeing? 

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

rousnay
Shopify Partner
5 0 1
Hi thank you for your reply,
 
I am getting "No shop provided", as a response:
 
My code is below:
 
app.post("/api/notification_reciever", async (_req, res) => {
 
const payload = _req.body;
 
const fulfillment = await shopify.api.rest.Fulfillment({session: res.locals.shopify.session});
 
fulfillment.line_items_by_fulfillment_order = [
{
"fulfillment_order_id": payload?.id
}
];
 
fulfillment.tracking_info = {
"number": payload?.tracking_number,
"url": payload?.tracking_url
};
 
await fulfillment.save({
update: true,
});
 
 
res.json("Fulfillment notification recieved!");
res.status(200).end();
});



Thanks again Liam 🙂

ryintl14
Shopify Partner
6 0 0

I got the same issue. Did you solve it? 

kasheen110
Shopify Partner
2 0 0

any update? 🙏