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.

  • JeroenL
    JeroenL Member

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

  • JeroenL
    JeroenL Member

    Hi, Thank you very much for your reaction.

    That one works!!!