How to – Submit multipart/form-data using HTTP action in Power Automate (Dataverse)


Recently we were calling an API (that expects multipart/form-data) to pass the image uploaded in Dataverse’s Image Column.

We used Power Automate for this i.e. to get the image uploaded and use HTTP Action to call and pass the Image details to it.

Below is the specification of the API

https://vision.foodvisor.io/docs/#/paths/analysis/post

We used the “Download a file or an image” action to get the Image details

Below is how the HTTP action was used to pass the required details.

The successful response –

The body of the HTTP action –

{
"$content-type": "multipart/form-data",
"$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"image\"; fileName=\"@{items('Apply_to_each_2')?['filename']}\""
      },
      "body": @{body('Download_a_file_or_an_image')}
    }
  ]
}


If we want to pass more than one data, we can have multiple headers defined as shown below

Helpful post –

Hope it helps..

Advertisements

The ‘Retrieve’ method does not support entities of type ‘fileattachment’ – Power Automate / Dataverse


We were getting the below error on using the “Get a row by ID” action on the FileAttachments table.

We were doing it to retrieve the details like the file name and the mime type for the Image Column.

The ‘Retrieve’ method does not support entities of type ‘fileattachment’. MessageProcessorCache returned MessageProcessor.Empty.

The solution here is to use List rows action instead.


The corresponding record –

Also check – https://temmyraharjo.wordpress.com/2021/09/02/dynamics-crm-plugin-development-exploring-file-and-image-datatype/

Hope it helps..

Advertisements

Fixed – To start using cloud flows, update to the latest package in the admin center (Power Pages)


Recently while trying to implement the below feature –

How to: Integrate Power Automate cloud flow with a Power Pages site

We were getting the below error –

To start using cloud flows, update to the latest package in the admin center.”

However, we could not find any portal package to apply the update.

We raised a Microsoft Support Ticket for it, and the team confirmed that there was a missing CDSBasePortal package, which they installed from the background, which solved the issue for us.

Hope it helps..

Advertisements

Fix – Forbidden. There’s a problem with the flow’s trigger. Fix the trigger (Power Automate / Flow / Dataverse)


Recently we got the below error “Forbidden” for one of our flows that was using the Dataverse connection.

After some analysis, we found the root cause of the error.

The Dataverse connection reference was created using the Service Principal but it was not added as an Application User (with appropriate security role) in that environment.

Adding the corresponding Application User used for the Dataverse connection fixed the issue for us.

Hope it helps..

Advertisements

Invoke webhook from a plugin – Dataverse / Dynamics 365

The content describes invoking a Webhook from a custom Azure-Aware Plugin, registered through a plugin registration tool. It includes code to invoke the Webhook using the IServiceEndPointNotificationService interface and a sample code snippet. The process involves updating a case record and provides guidance on the execution context and handling exceptions.


Similar to Azure Service Bus, we can invoke a Webhook from a plugin (custom Azure-Aware Plugin)

Below is our cloud flow that we have registered as a webhook through the plugin registration tool.

Below is our Webhook registered, note down the ServiceEndpointId.

Below is our code to invoke the Webhook, it uses the same interface, and we IServiceEndPointNotificationService need to provide ServiceEndpointId to it.

We have this registered in the Update message of the Incident.

Let us update a case record and see it in action.

Sample Code –

 public class CallWebhookPlugin : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {           
            ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));
            IServiceEndpointNotificationService webHookService = 
                (IServiceEndpointNotificationService)serviceProvider.GetService(typeof(IServiceEndpointNotificationService));

            try
            {
                tracingService.Trace("Posting the execution context to the Webhook.");
                // pass the GUID (ServiceEndpointId) of the Webhook 
               webHookService.Execute(new EntityReference("serviceendpoint",
                    new Guid("7b88a3c7-d2b5-ee11-a569-0022481c0ba7"))
                    , context);                            
                tracingService.Trace("Passed Successfully.");              
            }
            catch (Exception e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());
                throw;
            }
        }

Hope it helps..

Advertisements

Concurrency Control – Apply to each for improving performance (Power Automate / Dataverse)


Let us fetch 5000 contact records using List Rows, and then update it using Apply To Each.

It took around – 37 minutes

Now let us enable concurrency control for Apply To Each action, and let it run under 20 (default) degree of parallelism.

This time it took around 4 minutes.

Let us increase it to the maximum this time, i.e. 50.

This time it took around 2:45 minutes.

Thus Concurrency Control option can help in processing records faster by processing records in parallel instead of one by one by using parallel threads. However, if the ordering of the way records need to be processed is critical, then we need to be careful before using it and also at times it can cause the API’s request limit to be hit.

Get more details on Concurrency limits

Hope it helps..

Advertisements