How to make rest calls to /admin/metafields.son from APPBRIDGE

Shopify Partner
14 1 0

Hi, I am new to Shopify App development, and am using APPBRIDGE to build my embedded app based on THIS tutorial.

 

My app has a requirement to store some global app settings in the shop's Metafields. I had been planning to use GraphQL for the whole app, but discovered that this functionality is only available via the REST interface:

POST /admin/metafields.json

 Can someone share how I can make these REST calls given the above technology stack?

 

Thanks!

Mike

0 Likes
Highlighted
Shopify Expert
9819 92 1581

I'll skip your question for the moment and ask you another. What data do you need to store in a shop metafield? Metafields are not a protected resource so if you're storing critical settings in there keep in mind another app/tool could alter or delete them. If that's a problem then metafields are not the right place for that data.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
14 1 0

Hi Jason,

 

We will store global settings that are used internally by our app that are specific to the shop.

We are not worried about another app maliciously manipulating data within our namespace.

That being said, is this a problem faced by other app developers?

 

Thanks!

Mike

0 Likes
Highlighted
Shopify Expert
9819 92 1581

There certainly could be some app devs out there that don't want to store app specific data on their own servers. I hope none do as it's a poor/risky approach given how quick it is to spin up some form of db app side. It also creates garbage in the shops metafield data come uninstallation time. Your app may be removed but the metafield will still remain.

 

In the REST API docs there's an example for creating a shop metafield.
https://help.shopify.com/en/api/reference/metafield#create

Where did you get stuck?

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
14 1 0

I need a code example. I am very new to this technology stack, and am completely lost as to how to make a rest call using APPBRIDGE.

 

0 Likes
Highlighted
Shopify Partner
14 1 0

Hi Jason,

 

I looked at the link you provided. I get that this is the endpoint for writing an admin metafield.

 

The problem I am having is that I do not know how to use APPBRIDGE to do a post?

 

Can you point me to an example of how to accomplish this with APPBRIDGE?

 

Thanks!

Mike

0 Likes