November Happy Hour will be moved to Thursday December 5th.

Importing media using the episerverapi/commerce/import/assets with file

Vote:
 

Hi, 

I have tried to understand how to generate media.xml file following the instructions here and the the given XSD, but I couldn't figure it out by myself.

Currently I have images uploaded to blob storage in DXC. Catalog has been imported using the /episerverapi/commerce/import/catalog

This is what I figured out xml should look like:


  
   VanillaAzure.Models.Media.GenericMedia, VanillaAzure
  
  
   
    TEST_ENTRY_MEDIA
    TEST_ENTRY_MEDIA
     
      
       TestProperty
       This media item has no blob and no associations.
      
     
     
      maxresdefault.jpg
     
     
      
       1238704
       SomeProductGroup
      
     
     
      
       1238704_1
       SomeVariantGroup
      
     
    
   

If I understood correctly image and media.xml should be zipped and posted to /episerverapi/commerce/import/assets

Using Postman for posting zip file to upper mentioned URL  I get 200 response but no image gets uploaded to the global assets folder.

Question is if the image and the media.xml should really be zipped prior to calling the import/assets ? Is there any real life example of how media.xml should look like in order to upload images and link them to both products and variants?

[Pasting files is not allowed]

#184868
Edited, Nov 06, 2017 14:07
Vote:
 

You can see example here

#184878
Nov 06, 2017 20:11
Vote:
 

Thanks. That helped a lot.

#185009
Nov 08, 2017 12:08
Vote:
 

Just in case someone ends up having the same issue when importing multiple files in the same zip file. 

It's possible to have media files and media.xml zipped in one file. 

ContentProperty tag describes properties of the media file. Type tag is case sensitive. (string fails - String passes)

<MediaType name="ImageFile">
    <ContentType>Namespace.ImageFile, ProjName</ContentType>
    <ContentProperty>
      <Name>Description</Name>
      <Type>String</Type>
    </ContentProperty>
</MediaType>

XML for importing images has to have this form

<MediaGroup mediaTypeName="ImageFile">
    <Media>
      <IntegrationId>unique_id</IntegrationId>
      <Name>2158</Name>
      <BlobContent>        
        <FileInArchive>name.jpg</FileInArchive>
      </BlobContent>
      <CatalogEntries>
        <Association>
          <Code>542252</Code>
        </Association>
        <Association>
          <Code>542252_1</Code>
        </Association>
        <!--more associations for the same image can be listed here -->
      </CatalogEntries>
    </Media>
  </MediaGroup>
  <MediaGroup mediaTypeName="ImageFile">
    <Media>
      <IntegrationId>unique_id_1</IntegrationId>
      <Name>2159</Name>
      <BlobContent>
        <FileInArchive>name-1.jpg</FileInArchive>
      </BlobContent>
      <CatalogEntries>
        <Association>
          <Code>619824</Code>
        </Association>
      </CatalogEntries>
    </Media>
  </MediaGroup>
</MediaImport>

Every asset file has to have MediaGroup element wrapped around it. Inside CatalogEntries it's possible to list all entries which will use one image.

#185393
Nov 17, 2017 13:19
Vote:
 

Hi,

did something happen to this endpoint? All of a sudden I started to get 404. I can get token. I can import catalog with /episerver/commerce/import/catalog so routes are properly set, but when media.zip gets sent to this endpoint (and it worked earlier) I keep getting 404.

ServiceAPI.Commerce nuget is version 4.2.1

#188245
Feb 15, 2018 13:29
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.