microsoft-dynamicsdynamics-crm-webapi

Download image using Dynamics 365 Web API


I am trying to download the image from Dataverse using Dynamics Web API.

I am able to succeed in that using {{webapiurl}}sample_imageattributedemos(d66ecb6c-4fd1-ec11-a7b5-6045bda5603f)/entityimage/$value

But when I try to download the full/actual size image - I am getting the file with the reduced size - {{webapiurl}}sample_imageattributedemos(d66ecb6c-4fd1-ec11-a7b5-6045bda5603f)/entityimage/$value?fullsize=true.

I tried to download the image using the sample code where additionally I have added CanStoreFullImage = true attribute.

Please find below code snippet for the reference:

CreateAttributeRequest createEntityImageRequest = new CreateAttributeRequest
{
    EntityName = _customEntityName.ToLower(),
    Attribute = new ImageAttributeMetadata
    {
        SchemaName = "EntityImage", //The name is always EntityImage
                                //Required level must be AttributeRequiredLevel.None
        RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
        DisplayName = new Microsoft.Xrm.Sdk.Label("Image", 1033),
        Description = new Microsoft.Xrm.Sdk.Label("An image to show with this demonstration.", 1033),
        CanStoreFullImage = true,
        IsPrimaryImage = false,
    }
};

How can I achieve this - to download the full size image using Web API?


Solution

  • the correct syntax is size=full, not fullsize=true

    to build such requests you can use my tool Dataverse REST Builder, you can find the operations to deal with Image fields under the Manage Image Data request type