Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

406 api error #37

Closed
nithinnitzarya opened this issue Jun 6, 2018 · 5 comments
Closed

406 api error #37

nithinnitzarya opened this issue Jun 6, 2018 · 5 comments

Comments

@nithinnitzarya
Copy link

Hi,
I tried to insert a code using asset API of Shopify. but it returned a 406 error - Client error: PUT https://good-time-store.myshopify.com/admin/themes/14690353211/assets.json resulted in a 406 Not Acceptable response

This is my code
$api = $shop->api();
$asset = [
[
'key' => 'layout/theme.liquid',
'value' => 'hello'
]];

    $result = $api->request(
        'PUT',
        '/admin/themes/14690353211/assets.json',
        ['asset' => $asset]
    );
@ncpope
Copy link
Contributor

ncpope commented Jun 6, 2018

@nithinnitzarya try

$asset = [
    'key' => 'layout/theme.liquid',
    'value' => 'hello'
];

It looks like you have an unnecessary array

@nithinnitzarya
Copy link
Author

@ncpope

I changed that but again got an another error - Client error: PUT https://good-time-store.myshopify.com/admin/themes/14690353211/assets.json resulted in a 422 Unprocessable Entity response: {"errors":{"asset":["Missing {{content_for_header}} in the head section of the template","Missing {{content_for_layout}} (truncated...)

@nithinnitzarya
Copy link
Author

nithinnitzarya commented Jun 7, 2018

@ncpope @ohmybrew Any Solution? still am getting these errors. I have tried a lot of combinations

@brianakidd
Copy link

@nithinnitzarya keep in mind this package provides a wrapper to Guzzle for making the HTTP request. What @ncpope recommended resolved the 406 error - have you looked specifically at the 422 error response in terms of the missing content?

The 422 is telling us that the request was processed by Shopify's API and it didn't meet the validation for updating the underlying resource.

Hope this helps.

@nithinnitzarya
Copy link
Author

@brianakidd @ncpope Wow !!! Finally !! Validation was the issue. I was trying to write on the theme file without header and layout.
I have added that and the error vanished ;)
Thanks a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants