Create/Update using Assets API on Shopify React/Remix custom app returns 404

Hi everyone,

I’m currently trying out to duplicate a pdp theme template via custom app (part of a bigger feature). To do so, I believe this Rest API reference should do the thing: Reference Link

I believe these are the only requirements needed for it to work:

  • write_themes scope added

  • API version set to 2024-01

I have also tested it in POSTMAN and I can verify that it works using the Develop App credentials. However, for our React/Remix custom app, it doesn’t.

Here’s the example of code:

export const action = async ({ request }) => {
   const { admin, session } = await authenticate.admin(request);
   const asset = new admin.rest.resources.Asset({session: session});

   asset.theme_id = "123456"; // replace with valid theme id
   asset.key = "templates/test-pdp-template.json";
   asset.source_key = "templates/product.json";

   await asset.save({ update: true });
}

Given example is for test sake. When submit is executed, it should create a pdp theme template based from the templates/product.json which by default exists. However, what I’m getting is 404.

Did I miss something?

Hi Charles,

Just to confirm, the React/Remix based app is not set up to be a public app, correct?

Hi Liam,

That’s right, it’s not set to be public. The custom app will be used internally only.

There’s a couple things you could try to narrow down what’s happening:

  • Can you try adding the read themes scope too to see if this makes a difference?
  • Could you try testing to see if there any other API calls (eg: creating a product) that are not working, or if it’s only calls to the Asset API?
  • Check if the code that works in postman is the exact same?

Hey Liam,

Yes, **read_themes** is already added too. Here’s the scopes that we’re using:

scopes = "read_products,write_products,read_orders,write_orders,read_customers,write_discounts,read_metaobjects,read_metaobject_definitions,read_themes,write_themes"

In Shopify Partner:

Here’s a screenshot of the successful test I made in postman:

Can confirm too that I can create product using the admin.rest.resources.Product. Here’s an example of my code:

export async function createProduct(request) {
  const { admin, session } = await authenticate.admin(request);
  
  const product = new admin.rest.resources.Product({session: session});
  product.title = "1 Test Product from custom app";
  product.body_html = "**Test Description**";
  product.status = "draft";
  await product.save({
    update: true,
  });
}

Screenshot of the product that got created:

Hey Liam,

Regarding the “request for protected access” this is the note that I was referring to:

Not sure where to request that as it is nowhere to be found in the Partner dashboard.

This request for access should only be required if your app is a public app - and it should not apply to custom apps. Will connect with our internal dev team to try to understand why this is happening.

Alright, thank you for clarifying regarding that. Looking forward for your response about this matter.

Have a great day ahead Liam!

Hi again Charles,

Still looking into this, are you 100% certain that the credentials you are using in Postman to successfully make a PUT request to the Asset API are the same as the one that is failing in the remix app?

Hey Liam,

I think I have mentioned in one of my reply that I was using a Develop App’s credentials in postman (the one that you can create via “Apps and sales channels” option in the settings). So I believe it is using a different one than the remix app.

Okay - I think that may be the issue, it’s very possible that the credentials that you’re using on the remix app is associated with an app that is not set up as a custom app. You may need to connect with our partner support team to look into this app specifically to confirm.

Hi Liam,

Will file a ticket to the partner support team regarding this.

Really appreciate you looking into this.

Thanks,

Hello @CharlesMoreno and @Liam , there are any news on the Assets API PUT Remix app?
I’m encountering the same issue.
We have developed an app that relies on AssetsApi, it is already in production. It has the exemption to use the AssetsAPI.

For now, the production app works, but on local environment it does not work anymore, even trying to downgrade version of the shopify-api, I tried 2023-01, 2023-10, and 2024-01.
Assets API for the GET works fine.
There is no doubt that the API request is well written, as it is the same a per Shopify’s documentation and also, is the same as the one in Prod which is currently working, and no changes were done.

Let me know, anything that could be helpful. Thank you!

Hi @WarrenWolff ,

I feel bad that you’re encountering the same but that’s great to know that I’m not the only one that’s having this problem. I already escalated this issue via sending a support ticket in the Shopify Partner dashboard. I already gave them all the essential information that they need and just waiting for their response about it.

Will definitely update you once I hear from them.

Hey @WarrenWolff ,

While I’m in the process of giving them more information about the problem that we’re facing. My last test without changing anything seems to have worked already. I was able to create/modify assets using the Assets API in the Remix App.

I already asked for a confirmation whether they released a fix for it already. Let me know if it is the same on your end.

Thanks,

Charles Moreno

Hey @WarrenWolff ,

Just received the confirmation from them that they have rolled out a fix for it! Hopefully it is resolved on your end as well.

Have a great day!

Thanks,

Hi @CharlesMoreno , fantastic news for you.
I just tested and unfortunately for me it is not yet working. Now I’m wondering why it works for you. Maybe ApiVersion or node package.
I’m using 2024-01 on shopify.server.ts and I’m also using new admin.rest.resources.Asset({ session }) to then asset.save(), one thing that is worth to check with you is the package version:

@shopify/shopify-api”: “^9.0.1” → which scaffolds the 9.0.2

Nothing, I tried package @Shopify_77 /shopify-api:9.2.0 which was release 1 hour ago more or less. And it still doesn’t work, it is quite incredible.

Hi @WarrenWolff ,

Sorry for getting back to you late.

I just verified again that it is indeed not working again.

I will reach out again to the support regarding this. Hold on tight, will update you soon!

Hey @WarrenWolff ,

I just noticed from your screenshot that you’re still getting a 404 error rather than 422. Have you tried to check your Shopify Partner App if it’s already distributed as a custom app? You can do so by going to the “Distribution” then choose “Custom Distribution”. Take note that this does not entirely resolve your issue.

After that, your app should have a “Custom App” tag when viewed in the apps list. With that, the error changed from 404 to 422 to me. Will update you soon once I hear back from the support of why we’re still getting these errors.