406 Error on Asset PUT request

benlehman
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
Jason
Shopify Expert
10254 142 1940

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.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
benlehman
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
Alex
Shopify Staff
Shopify Staff
1555 81 295

@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.

benlehman
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
Alex
Shopify Staff
Shopify Staff
1555 81 295

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
Kim30
Shopify Expert
135 0 8

Did you ever find a solution? I'm having what sounds like the same problem - I can get, but putting is causing a 406

The eChics are here to help
0 Likes
Avi_Ben_Zaken
New Member
1 0 0

same same here.

any valid suggestions???

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 226

I just tried a test PUT request to this API endpoint and it came back fine. Screen shot below. And to make sure of no differences in API version, I was successful against 2020-10 as well. Perhaps verify the theme ID is valid? And you are passing along the authorization credentials in the request header and not in the URL, correct? 

 

Untitled.png

0 Likes
amrooz
Tourist
5 0 0

if you're using node remember to use JSON.stringify in body, for me that was the case ...

0 Likes