Solved

Unusual response when upload image on products

DanieleB
Shopify Partner
7 0 0

Hi,

 

I'm using a private app to manage our shops, in order to sync the products from the ERP used by my company.

We want to update the product images via API, because we still upload them manually when a new product is created.


the request JSON is formatted like this:

{
	"image": {
		"attachment": "BASE64_ENCODED_IMG",
		"filename": "product_name.jpg"
	}
}

 

When we try to send the POST request to the API, the response is always like this:

<html>
    <body>
        <noscript>
            <a href="https://app.shopify.com/services/login/identity?destination_uuid=56e64392-1b89-47c2-945f-a430db39311a&amp;return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3DVelasca%26state%3Dk7-lDNTutsmP8EIs3l6dRYEjNr5U54uS9pbNKSTFmsW2rmglTGJWBhaPRBGhHTMHdUMKh9XNAFS5qIIGa08VPwffiWzFg69mKAufQ_Ys5IfQel_ZqxMOPFOZN6ZYGUaI9Vu6OBY8aqX6vCLhXo7YQhK93SkPKYGkLvwKzjd9gyDzPV6mumDJah6nCSqO3bguzgiVcBCq5fe0WHS18NYl9vrqjBCvaDYPuvq6Q5uUhBU%253D&amp;ui_locales=en&amp;ux=shop">Continue</a>
        </noscript>
        <script type="text/javascript">
      window.location = "https:\/\/app.shopify.com\/services\/login\/identity?destination_uuid=56e64392-1b89-47c2-945f-a430db39311a\u0026return_to=https%3A%2F%2Fapp.shopify.com%2Fservices%2Flogin%2Fidentity_callback%3Fshop_name%3DVelasca%26state%3Dk7-lDNTutsmP8EIs3l6dRYEjNr5U54uS9pbNKSTFmsW2rmglTGJWBhaPRBGhHTMHdUMKh9XNAFS5qIIGa08VPwffiWzFg69mKAufQ_Ys5IfQel_ZqxMOPFOZN6ZYGUaI9Vu6OBY8aqX6vCLhXo7YQhK93SkPKYGkLvwKzjd9gyDzPV6mumDJah6nCSqO3bguzgiVcBCq5fe0WHS18NYl9vrqjBCvaDYPuvq6Q5uUhBU%253D\u0026ui_locales=en\u0026ux=shop";
    </script>
    </body>
</html>

Also, I got this same response when I try to upload the image by adding a URL.

 

I checked the app's permissions and they seems to be correctly configured.

I made a GET request and I receive a regular JSON response with the images set for said products.

What can it be?

Accepted Solution (1)

KarlOffenberger
Shopify Partner
1873 184 901

This is an accepted solution.

Shopify prevents HTTP Basic Auth POST requests that have cookies, which can cause POST calls to fail. If your POST call fails, then you should try clearing your cookies.


from docs.

 

In short, you're probably sending cookies in your request header.

 

cookie-monster-diabetes

 

Best wishes!

View solution in original post

Replies 4 (4)

KarlOffenberger
Shopify Partner
1873 184 901

This is an accepted solution.

Shopify prevents HTTP Basic Auth POST requests that have cookies, which can cause POST calls to fail. If your POST call fails, then you should try clearing your cookies.


from docs.

 

In short, you're probably sending cookies in your request header.

 

cookie-monster-diabetes

 

Best wishes!

DanieleB
Shopify Partner
7 0 0

Thanks!

After clearing the cookies, the POST request was succesful!

Thanks again!

DamonJones
Visitor
1 0 0

Hi,

 

I am getting the same error with C# onn WinForm. How to clear the cookie on the WinForm?

 

Cheers,

DJ

DanieleB
Shopify Partner
7 0 0

Hi, even it isn't the place to discuss WinForm solutions, I made a research about it:
https://stackoverflow.com/questions/912741/how-to-delete-cookies-from-windows-form

Does it solve your problem?