406 Error on Asset PUT request

Tourist
3 0 0

Hey,

 

I'm having an issue getting a 406 Error whenever I make a PUT request to https://{key}:{password}@{host}/admin/api/2019-07/themes/{theme.id}/assets.json. I'm have a private app running on the site, and am able to make GET requests successfully but not PUT requests.  Here's the body for my request, based off of this Shopify Documentation:

 

 

{
  "asset": {
    "key": "assets/empty.gif",
    "attachment": "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"
  }
}

I've also tried sending this as the body of the request as well:

{
  "asset": {
    "key": "assets/test.liquid",
    "value": "<h1>Test</h1>"
  }
}

I'm using Postman to make sure that I'm not doing something wrong within my app, which I set up based on this Shopify documentation. I also have Read & Write access for theme & theme assets given to my app, and I've triple checked to make sure I have the correct theme ID. 

 

 

Any idea on why I would be getting a 406 error? Are there any specific Headers that need to be added to this kind of request for Shopify to accept it?

 

I appreciate the help!

 

0 Likes
Highlighted
Shopify Expert
9789 86 1531

In postman, remove any cookies you are sending and try again. If you're only using the online version you won't be able to make post requests that way if using the key/password method of authentication.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Tourist
3 0 0

Hey Jason, I appreciate the help! I removed all cookies from Postman's Cookie manager (I'm using the native app), but I'm still getting the 406 error for my PUT requests. My GET requests are getting through fine though. Is there any information that I could provide that would be relevant in figuring out what the issue is? Would seeing the header response I get back from my PUT request be helpful?

0 Likes
Shopify Staff
Shopify Staff
1555 79 245

@benlehman you can make note of an X-Request-Id response header and let me know what the value for that is. I can use that to check logs and look more directly at the request you made to see what might be happening.

 

Cheers.

1 Like
Tourist
3 0 0

Hey @Alex here's the X-Request-Id I get from the PUT request, e668c5d6-6f3d-487c-8133-ecafcde160bc
For that PUT I sent the following as the body: 

{
  "asset": {
    "key": "assets/empty.gif",
    "attachment": "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"
  }
}

I also sent another PUT request with the following as the body:

{
"asset": {
"key": "snippets/test.liquid",
"value": "<p>Test</p>"
}
}

And for that request the X-Request ID was: 2c48a45e-8846-4f3f-a5e3-5f0dcfee8161

 

I appreciate the help!

0 Likes
Shopify Staff
Shopify Staff
1555 79 245

That's strange. I'm not seeing anything obvious, but are you able to try a basic curl request rather than Postman to try ruling out the client?

 

Cheers.

0 Likes