Unusual response when upload image on products

Solved
Highlighted
Shopify Partner
6 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?

0 Likes

Success.

Shopify Partner
1843 171 542

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!

I turn coffee in to code - since 1998
1 Like
Shopify Partner
6 0 0

Thanks!

After clearing the cookies, the POST request was succesful!

Thanks again!

0 Likes