RestAPI OTDS create a group

Hi, I am looking for an example of creating a new OTDSGroup in OTDS via RestAPI.

This OTDS group must be created in a specific existing user partition.

Also the authentication part for OTDS. is still unknown if there are any examples for that as well that would be appriciated.

Thx

Answers

    1. access your OTDS swagger UI using https://<otds server>/otdsws/api/index.html?rest
    2. Click on authorize and login as otds-api (no need to provide client-secret)
    3. Use "try it out" button in the "Create a Group" API and provide name and location in the request
    4. Click on Execute to send the request to OTDS
    5. Check the curl request and implement accordingly in your application.

  • Hi Vishal_K,

    Thanks, that information helped me a lot.

    But I still have a question on how I can logging into OTDS via code in a C# application.

    Thx.

  • there is an authentication API available (/authentication/credentials). Enter username/password in the request and you should get OTDSTicket in the response. Which you can then use it in subsequent request's header.

    If you use SSO, then use the Authenticate by HTTP Headers (/authentication/headers) API to get the OTDSTicket.

    OTDS Documentation available on https://developer.opentext.com/ce/products/opentext-directory-services/apis/otds-rest-api-24-1-0

    Hope this helps.

  • Hi,

    In C# code i do the folllowing:

            string otdsRestAPIURL = @"https://URL:1234/otdsws/rest/";

    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(otdsRestAPIURL);

    client.DefaultRequestHeaders.Accept.Clear();
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));

    List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
    parameters.Add(new KeyValuePair<string, string>("username", "MyUser"));
    parameters.Add(new KeyValuePair<string, string>("password", "MyPassword123"));
    parameters.Add(new KeyValuePair<string, string>("ticketType", "OTDSTICKET"));

    HttpResponseMessage response = client.PostAsync("authentication/credentials", new FormUrlEncodedContent(parameters)).ConfigureAwait(false).GetAwaiter().GetResult();
    if (response.IsSuccessStatusCode)
    {
    string s = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();





    }

    But this fails with a status code 415.

    {StatusCode: 415, ReasonPhrase: '', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
    X-OneAgent-JS-Injection: true
    Server-Timing: dtRpid;desc="192376001", dtSInfo;desc="0"
    X-XSS-Protection: 1
    X-Content-Type-Options: nosniff
    Keep-Alive: timeout=120
    Connection: keep-alive
    Cache-Control: no-store, no-cache
    Date: Thu, 21 Nov 2024 11:36:12 GMT
    Set-Cookie: dtCookie=v_4_srv_11_sn_0F8798559D61C11120DFC6A8D6E0889E_perc_100000_ol_0_mul_1_app-3Adadffc70e35e12c2_1_rcs-3Acss_0; Path=/; Domain=.MyDomain; SameSite=Strict; secure
    Server:
    Content-Length: 1
    Content-Type: text/html; charset=ISO-8859-1
    }}

    Any Idea why this is not working?

    I use the same constructions as for the Content Server RestAPI calls.

    Best regards,

    Jeroen

  • Compare it with this working code

    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, "https://otds_server/otdsws/rest/authentication/credentials");
    var content = new StringContent("{\r\n "userName": "myuser",\r\n "password": "mypass"\r\n}", null, "application/json");
    request.Content = content;
    var response = await client.SendAsync(request);
    response.EnsureSuccessStatusCode();
    Console.WriteLine(await response.Content.ReadAsStringAsync());

  • Hi, Thank you very much for your reaction.

    That one works!!!

  • JeroenL
    JeroenL Member
    edited November 28 #8

    Hi,

    I am able to create an OTDS group and add MemberOf groups to that OTDS group. But I am not able to add Members.

    The error I am getting is:

    {  "status": 2001,  "error": "RuntimeException: Invalid DN: OTDS-IPO_Acceptatie_Historie-L",  "errorDetails": null}
    

    GroupID —> OTDS-Test_NewGroup@OTDS

    member_attr —> entryDN

    validate_members —> false

    Group members —> {"stringList":["OTDS-IPO_Acceptatie_Historie-L"]}

    I think I do not have the correct member_attr value, but where can I check which value I have to set?

    Both groups exist in OTDS, in the partition OTDS.

    Best regards,

    Jeroen

  • entryDN is Distinguished Name (DN) of a specific entry within the Active directory. It looks something like this

    "oTPerson=6g587hc6-eh490-4d86-8786,orgunit=**** Administrators,partition=ABC-WN-VA-Admins,dc=identity,dc=opentext,dc=net"

    So you can either get that from AD or by calling GET /users/{user_id} api

  • Hi,

    Thank you for your answer!

    I would like to add an existing OTDS group (OTDS-IPO_Acceptatie_Historie-L) as a member to the new OTDS group (OTDS-Test_NewGroup). When I use the value:

    oTGroup=d26fc870-8527-4de5-9ba3-00d5eace2f3c,orgunit=Root,partition=OTDS,dc=identity,dc=opentext,dc=net

    for member_attr I am getting the following error:

    {  "status": 3010,  "error": "Unsupported attribute for referencing members",  "errorDetails": null}
    

    The oTGroup was the value for the OTDS Group to which I would like to add the member.

    Using the other oTGroup values gives the same error message.

    I hope you have a way to make this work

  • Do you have to pass member_attr field? IMO, You dont need to.

    The below curl request works for me. I was able to add group to another group.

    curl -X 'POST' 'https://«OTDS»/otdsws/rest/groups/test_automation/memberof'

    -H 'accept: application/json'

    -H 'Authorization: Bearer '

    -H 'Content-Type: application/json'

    -d '{
    "stringList": [
    "oTGroup=bbfe4ce0-7ffe7d1,orgunit=groups,partition=Content Server Members,dc=identity,dc=opentext,dc=net"
    ]
    }'

  • Hi,

    That was the trick, so in de stringlist you must enter the DN name. when adding members.

    When adding memberof I can add them using the Name of the existing otdsGroup.

    Thanks I can make it work now.