Contact me!
Eric Håård
+46 (0) 73 375 86 06

ImportImage

C# example code for the ImportImage method

Used to upload images on SKUs in Storm Commerce, keys are:

  • PartNo – SKU identifier
  • ExternalCode – Image identifier

Additional fields:

  • FileType – Specifies type of file. These must be configured in the platform by the Storm Commerce development team.
  • Url – Url to image, can be a public http, ftp or ftp together with username and password, i.e. ftp://username:password@hostname/

SKU must already exist in Storm, if not – image reference is saved and uploaded, but no resolvement to SKU is made.

Example code:

static void Main()
{
    var serviceUrl = "https://stormstage.enferno.se/StormConnect/4.0/api/";
    var applicationId = 0;
    var secretKey = Guid.NewGuid();

    var job = ImportImage(serviceUrl, applicationId, secretKey);
}

public static JobDto ImportImage(string serviceUrl, int applicationId, Guid secretKey)
{
    const int accountId = 0;

    var imageHeader = new ProductHeader
    {
        AccountId = accountId
    };

    var requestUri = new Uri(new Uri(serviceUrl), "product/ImportImages");
    var myRequest = new MyRequest<ProductHeader, PartNoImage>(imageHeader, GetImages());
    return RestHelper.SendStreamedData<JobDto, ProductHeader, PartNoImage>(
        requestUri.AbsoluteUri, applicationId, secretKey, myRequest);
}

private static IEnumerable<PartNoImage> GetImages()
{
    // NOTE Format and map your data to the StormConnect standard here
    return new List<PartNoImage>
    {
        new PartNoImage
        {
            PartNo = "PartNo123", // NOTE This is required key for image
            ExternalCode = "Image123", // NOTE Code unique for specific image
            FileType = "Standard", // NOTE All filetypes must be configured in Storm
            Url = "http://www.enferno.se/Content/images/logo.png"
        }
    };
}

Related:
Querying job status