web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

Execute Multiple Request Error in Azure Function

(0) ShareShare
ReportReport
Posted on by 185

Hi All,

I have receiving an error while using the execute multiple request in the Azure Function:

Error:

An exception occurred in Execute Multiple: System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
The Architecture is something as follows: D365 CE <- Flows runs and checks for specific parameters -> Azure Function (it passes the required information as JSON body) -> D365 CE
Azure Function processes the body (Logical operation) and updates the list of records received and pushes the update to D365 CE.
If I used Postman to run the code, the status returned is OK. 
I cannot use single update function since it is bulk update and API limit will be reached. (It also works if single update function is used).
The code used is:
foreach (Entity entity in batch)
{
UpdateRequest updateRequest = new UpdateRequest();
updateRequest.Target = entity;
updateRequests.Add(updateRequest);
}

OrganizationRequestCollection requestCollection = new OrganizationRequestCollection();
requestCollection.AddRange(updateRequests);

ExecuteMultipleRequest execRequest = new ExecuteMultipleRequest()
{
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = true,
ReturnResponses = true
},
Requests = requestCollection
};

try
{
ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)service.Execute(execRequest);
}
catch (Exception ex)
{
throw new Exception("An exception occurred in Execute Multiple: " + ex.ToString());
}
  • Suggested answer
    Pankaj Gogoi Profile Picture
    3,177 on at

    It could be a data issue. You can debug and check which record is throwing error. Also check the stack trace and inner exception.

    Try sending small batch of data and see if that works.

    Good Luck

    Best Regards

    PG

  • Srinivas Naidu Profile Picture
    185 on at

    There is no data error, if I debug at the execute multiple request line, it is working fine using postman, status is OK. Only when hosted in Azure, it is throwing the error. That is the reason I am unable to identify and fix it.

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Can you check the Application Insights if it is logging additional information. it's emitting the response message in html and the application is trying to convert that html to xml, so the underlying issue could be something else.

    Good Luck

    Best Regards

    PG

  • Verified answer
    Srinivas Naidu Profile Picture
    185 on at

    I was able to resolve this issue doing the below:

    1. The URL that needs to be used while instantiating the IOrgservice must be:  your org url (like: xxxyyy.api.crm.dyamics.comm @"/.../web

    2. Have a null check in the code as necessary including running the execute requests.

  • kokane Profile Picture
    Microsoft Employee on at

    It is good to hear you resolve the issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 62 Most Valuable Professional

#2
11manish Profile Picture

11manish 23 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 10

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans