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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM Web API error 500 (Internal Server Error)

(0) ShareShare
ReportReport
Posted on by

Hi!

I'm trying to add a user to a team using CRM Web API from python script but was thrown with 500 response code (Internal Server Error).

In "C:\Program Files\Microsoft Dynamics CRM\Trace\*-CRMWeb-*.log" file several errors appeared:
- Failed to log the audit record into the database Procedure or function 'p_InsertMultipleAuditRows' expects parameter '@audituseradditionalinfo', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
- Crm Exception: Message: Failed to insert audit record, ErrorCode: -2147220970, InnerException: System.Data.SqlClient.SqlException (0x80131904): Procedure or function 'p_InsertMultipleAuditRows' expects parameter '@audituseradditionalinfo', which was not supplied.
- Web Service Plug-in failed in SdkMessageProcessingStepId: {1CB0FEB7-5A25-4032-8AC9-307C808580AA}; EntityName: team; Stage: 25; MessageName: AddMembers; AssemblyName: Microsoft.Crm.AuditRelationsPlugin, Microsoft.Crm.Audit, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.AuditRelationsPlugin; Exception: Unhandled Exception: Microsoft.Crm.CrmException: Failed to insert audit record
- MessageProcessor fail to process message 'AddMembers' for 'team'.
- System.Data.SqlClient.SqlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #67261A37: System.Data.SqlClient.SqlException (0x80131904): Procedure or function 'p_InsertMultipleAuditRows' expects parameter '@audituseradditionalinfo', which was not supplied.
- {"Error":{"InnerError":null,"Message":"FaultException`1: Failed to insert audit record"}}

Part of the script:
url = '<CRM_LINK>/api/data/v8.1/teams(<TEAM_ID>)/Microsoft.Dynamics.CRM.AddMembersTeam'
data = {
    'Members': [
        {
            'ownerid': <USER_ID>,
            '@odata.type': 'Microsoft.Dynamics.CRM.systemuser'
        }
    ]
}


We are using Microsoft Dynamics CRM 2016 8.1.0.359 version.

*This post is locked for comments

I have the same question (0)
  • crm development Profile Picture
    870 on at

    Hi,

    Would you give a try with below code which is working fine in my end.

    var parameters = { Members: [{ "ownerid": <USER_ID> }] };

    var req = new XMLHttpRequest();

    req.open("POST", <CRM_URL> + "/api/data/v8.1/teams(<TEAM_ID>)/Microsoft.Dynamics.CRM.AddMembersTeam", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204) {

               //Success - No Return Data - Do Something

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(parameters));

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Goutam,

    The link you have shared is broken but I am pretty sure that WEB API was introduced in CRM 2016 which is v8.0. You can verify this in the Rest Builder tool wherein you can create WEB API request for 8.0, 8.1 & 8.2 as well.

    Hope this helps.

  • gdas Profile Picture
    50,091 Moderator on at

    Thanks Ravi, for rectifying this, You are right.Actually I followed wrong reference .

    [View:https://community.dynamics.com/crm/f/117/t/265130]

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Goutam,

    That's the new enhancement on the existing WEB API which are introduced in 8.2, to be specific, returning entity data with create/ update using return=representation preference in the header of the request.

    docs.microsoft.com/.../gg309589(v=crm.8)

    Hope this helps.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Sergey,

    It looks like your code is correct. The problem is in frontend and I don't think you can fix it by yourself. I would recommend to open a ticket with Microsoft.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans