cancel
Showing results for 
Search instead for 
Did you mean: 

Images added via REST are missing properties

Images added via REST are missing properties

I'm trying to create products via the REST API in v2.3.3.  I can create the product, with it's properties, and add images to the product afterwards.  However, the primary image is missing the Roles, and all of the images are missing the Alt Text in the UI.  When I pull the product again via the API, it shows the images as they exist and both the types and label properly filled in.  What am I missing to get this working?

 

Here's the object that I'm sending to the "/products/{sku}/media" POST message (done in C# as a loop where "info" is the product, and "image" is each picture being added to the product).

new {
	entry = new 
	{
		content = new 
		{
			base64_encoded_data = image.content,
			name = image.fileName,
			type = image.mimeType
		},
		disabled = false,
		label = info.modelName,
		media_type = "image",
		position = idx,
		types = idx == 0 ? new List<string>() { "image", "small_image", "thumbnail" } : new List<string>(),						
	}
}

 

2 REPLIES 2

Re: Images added via REST are missing properties

So, new details as I've been doing more research on this item.

  • So pulled a copy of my product, via the API, and saved it for reference.  More important later.
  • The custom_attributes of the product show the proper image for each of "image", "small_image" and "thumbnail".  The same is also true for "image_label", "small_image_label" and "thumbnail_label" as well.
  • I went in to the admin UI and set the last (6th) image to be the "base", "small" and "thumbnail" image, along with adding "Alt Text" to the image.  When I pulled the product with the API again, it was still the same as it was before.
  • Using the admin UI, I removed the 2nd image from the product.  When I pulled the product, that image was gone, but the first image was still set as "base", "small" and "thumbnail".
  • Using the admin UI, I dragged the last image to be second-to-last.  When I pulled the product, the images were all still the same - same order in the array and same position for each image as well.

Not sure yet what's going on, or where the disconnect is at.  But, here's some additional information that may help trigger someone else's thoughts.

Re: Images added via REST are missing properties

More information that we've gleaned off the issue.

 

It appears that the images are being defined, but they're being defined for store_id = 1.  However, the product is on a web site that's under store_id = 5.  Is there anyway to define which store the media is good for?  Even setting it to "0" would work.  Looking through the documentation, I'm not seeing anywhere that I can indicate this level of control for the image when I upload it.  So, why is it automatically picking "1", and how do I go about selecting something else?