Adding a 'User's Account ID' to an existing 'Group' programatically

Hi,
I am using the following API to Add a User to an existing Group and getting Status: Ok as the response but still the User is not added as a member when checked through Dundas Interface.
API url :-
/api/group/AddMembers/4ea30ca2-c0d8-487c-ac9f-9b3ec43659cc?sessionId=b5f1632d-7a85-405a-950f-836466bb81e4

With the following Request Class-
public class ModifyGroupOptions
{
public Guid[] AccountIds { get; set; }
public Guid[] GroupIds { get; set; }
}
Is there is something wrong ?

Also in the documentation, Request class properties for the same API i.e. /Group/AddMembers/{id}/ seems to be different -

from what is there in the Console -

Hi Aseem,

If you are using Javascript, you can try the following script:

//Change this URL to point to your Host
var baseUrl = 'http://localhost:8000';

var logonOptions =
{

//Change these settings according to your credentials
    accountName: 'admin',
    password: '1234',
    cultureName: 'en-us',
    deleteOtherSessions: false,
    isWindowsLogOn: false
};

//Call for getting sessionID through LogOn API
$.ajax({
    type: 'POST',
    url: baseUrl + '/Api/LogOn/',
    data: logonOptions,
    success: function(logOnResultData) {
        var sessionId = logOnResultData.sessionId;

        var dataObject =
            { 
	// This is the Account ID of the user. Change it accordingly.         
                AccountIds: ["7c81082a-a3f9-41d9-a208-5fae46e8908d"]

            };

//Call for Adding Members to Group using /API/Group/AddMembers
        $.ajax({
            type: "POST",
            url: baseUrl + "/API/Group/AddMembers/f9228831-bd18-4e34-afd4-df3c9e7ba56d/?sessionId=" + sessionId + "",
            data: dataObject,
            success: function(data) {
            },
            error: function(data) { alert('failed' + data); }
        });
    }
});

More details on the /API/Group/AddMembers can be found at the link below:
https://www.dundas.com/support/api-docs/rest/#Dundas%20BI%20REST%20API%20Reference/Group/AddMembers/{id}/POST.html%3FTocPath%3DDundas%20BI%20REST%20API%20Reference|Group|_____3

I hope this helps.

Regards
Razi

Hi Razi,
Thanks, I am using the Rest API with c# code but have used in the same way as it is there in the JavaScript code. I am using the same API - /API/Group/AddMembers and also getting the Status as Ok but the changes are not reflected in dundas interface. Following is the code which I have used -
try
{
using (HttpClient httpClient = new HttpClient())
{
string groupID = “4ea30ca2-c0d8-487c-ac9f-9b3ec43659cc”;
Guid guidAccountId = Guid.Empty;
guidAccountId = new Guid(AccountId);
Guid[] accountIds = new Guid[1];
accountIds[0] = guidAccountId;

                string url = System.Configuration.ConfigurationManager.AppSettings["DundasAPIURL"].ToString() + "api/group/AddMembers/" + groupID + "?sessionId=" + SessionId + "";
              
                ModifyGroupOptions modifyGroupOptions = new ModifyGroupOptions();

                modifyGroupOptions = new ModifyGroupOptions()
                {
                    AccountIds= accountIds
                    //GroupIds = null
                };
           
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                string logOnTokenOptionsAsString =
                    javaScriptSerializer.Serialize(modifyGroupOptions);                

                HttpContent requestBody = null;
                requestBody =
                    new StringContent(logOnTokenOptionsAsString, Encoding.UTF8, "application/json");
                using (var response = httpClient.PostAsync(url, requestBody).Result)
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        string jsonObject = response.Content.ReadAsStringAsync().Result;
                        
                    }
                }

            }


            return string.Empty;
        }

Could you please look into that.

Thanks & Regards
Aseem

Hi Aseem,

I discussed the issue with our internally and was informed that this was a bug which has been fixed in version 6 under ticket#75580. I would recommend to upgrade to version 6 and try the same code and see if it works. Also, you can try creating your own version of ModifyGroupOptions class with correct property names, as follows:

public class MyModifyGroupOptions
{
public Guid[] accounts { get; set; }
public Guid[] groups { get; set; }
}

Then update the code to use “MyModifyGroupOptions” instead of “ModifyGroupOptions” and test the results.

Hi Abhay,

Thanks a lot. It is working now.

Thanks & Regards
Aseem