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)

AddUserToRecordTeam Web Api Action returns "Bad Request"

(0) ShareShare
ReportReport
Posted on by

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));

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Seems 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" }
    }


    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks much Goutam, it worked - not sure how I overlooked that

  • SOUNDHARYA.N.V Profile Picture
    165 on at

    Hi ,

    Can you share the working code. I am also finding the same issue.

    i have added teamtemplateid , still facing the issue

  • gdas Profile Picture
    50,091 Moderator on at

    Please share your code and the error details .

  • SOUNDHARYA.N.V Profile Picture
    165 on at

    Hi Please find the code below

    var parameters = {};

    var record = {};

    record.primarykeyid = "E0980A36-8C1C-E911-A98D-000D3A1BEE29";

    record["@odata.type"] = "Microsoft.Dynamics.CRM.account";

    parameters.Record = record;

    var teamtemplate = {};

    teamtemplate.teamtemplateid = "0CE30E9C-B789-E811-A839-000D3A33B56B";

    teamtemplate["@odata.type"] = "Microsoft.Dynamics.CRM.teamtemplate";

    parameters.TeamTemplate = teamtemplate;

    $.ajax({

       type: "POST",

       contentType: "application/json; charset=utf-8",

       datatype: "json",

       url: Xrm.Page.context.getClientUrl() + "/api/data/v9.1/systemusers(635F7E87-AF26-E811-A95D-00D3A1ABD0C)/Microsoft.Dynamics.CRM.AddUserToRecordTeam",

       data: JSON.stringify(parameters),

       beforeSend: function(XMLHttpRequest) {

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

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

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

       },

       async: true,

       success: function(data, textStatus, xhr) {

           var results = data;

       },

       error: function(xhr, textStatus, errorThrown) {

           Xrm.Utility.alertDialog(textStatus + " " + errorThrown);

       }

    });

                          });

    Error Message: {"error":{"code":"","message":"No HTTP resource was found that matches the request URI 'test.crm.dynamics.com/.../Microsoft.Dynamics.CRM.AddUserToRecordTeam&;."}}

  • Suggested answer
    Sneha Soma Profile Picture
    on at

    Make sure that your input json has the below schema:

    {

     "Record": {

       "@odata.type": "Microsoft.Dynamics.CRM.account",

       "accountid": "E331BB99-3329-E811-8136-480FCFEB2AF1"

     },

     "TeamTemplate": {

       "teamtemplateid": "bcddd715-b211-e811-8130-480fcfea0021",

       "@odata.type": "Microsoft.Dynamics.CRM.teamtemplate"

     }

    }

  • Suggested answer
    Siddique mahsud Profile Picture
    11 on at

    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

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