AddUserToRecordTeam Web Api Action returns "Bad Request"

116 views
Skip to first unread message

vijay kumar

unread,
May 8, 2019, 2:24:09 AM5/8/19
to Curso de Microsoft Dynamics CRM
Hi Everyone,

I am trying to programmatically add users to record access team, below is the request that returns `Bad Request` response, please advise -
(CRM Version 8.1.1.1707) Online, plugin is not a an option

var parameters = {};
var record = {};
record.primarykeyid = "E331BB99-3329-E811-8136-480FCFEB2AF1";
record["@odata.type"] = "Microsoft.Dynamics.CRM.new_test_entity";
parameters.Record = record;
var teamtemplate = {};
teamtemplate.primarykeyid = "bcddd715-b211-e811-8130-480fcfea0021";
teamtemplate["@odata.type"] = "Microsoft.Dynamics.CRM.teamtemplate";
parameters.TeamTemplate = teamtemplate;

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/systemusers(DAFDD716-59AF-E711-8127-480FCFEA2141)/Microsoft.Dynamics.CRM.AddUserToRecordTeam", 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 === 200) {
var results = JSON.parse(this.response);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(parameters));

Vikranth Sinha

unread,
May 17, 2019, 6:06:45 AM5/17/19
to Curso de Microsoft Dynamics CRM
Hi,

You have mentioned in parameter "primarykeyid" instead of "teamtemplateid". Replace with "teamtemplateid".

Try with this:

var parameter = {   
    "teamtemplate": { "teamtemplateid": "bcddd715-b211-e811-8130-480fcfea0021", "@odata.type": "Microsoft.Dynamics.CRM.teamtemplate" }
}

If you still need help regarding Microsoft Dynamics CRM Development feel free to contact me.

Siddique Mahsud

unread,
Sep 6, 2022, 12:24:31 PM9/6/22
to Curso de Microsoft Dynamics CRM

On the below link, I've posted a working example of calling the AddUserToRecordTeam action using web API. It May be helpful...

How to call AddUserToRecordTeam action using Web API

Regards,
Siddique

Reply all
Reply to author
Forward
0 new messages