Consuming OTDS API using REST Java

All,

Blocking your calendar to discuss on the below and request you to provide your inputs.

- We have created oauthclient and generated secrete id and passed in the code. 

- When we try to consume OTDS API from REST API (Java) we are receiving the error ‘no OTDS ticket’

Please request you to provide in case if you have any code snippet syntax for the above scenario which you have already implemented in one of your engagements.

Thanks

Balaji

Tagged:

Comments

  • can you share the code you are using so we can review and debug ?

  • tsbalaji86
    edited February 22, 2022 #3
    		HttpHeaders headers = new HttpHeaders();
    		headers.add("Authorization", "Basic "+"<<client-id>>:<<client-secret>>");
    		
    		headers.add("Accept-Encoding", "gzip, deflate, br");
    		HttpEntity<HttpHeaders> request = new HttpEntity<>(headers);
    		String mlEndpoint = String.format("https://<<otds>>/otdsws/rest/users/%s/", "<<user_id>>");
    
    		HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(
    	      HttpClientBuilder.create().build());
    		RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
    		
    		ResponseEntity<String> response = restTemplate.exchange(mlEndpoint, HttpMethod.GET, request, String.class);
    		if (response.getStatusCodeValue() == 200) {
    			try {
    					JSONObject myObject = new JSONObject(response.getBody());
    					System.out.println("The response from OTDS API is " +myObject)
    			   
    				}
    			} catch (JSONException e) {
    				e.printStackTrace();
    		}
    


  • Not seeing the authentication happening clearly in the code, as a simple test try it in something like PostMan to ensure you have it all working.

    You will need to authenticate first (authentication/credentials) to get a valid OTDS ticket, which is different from an OTCS ticket used for accessing Content Server.

  • would it be great if you are able to share some code snippet here in case you implemented in the past for OTDS please

  • relatively simple to get the OTDS ticket as per the above and then call the endpoint, e.g. "'/groups?where_partition_name=’+parName;" to get the details of that partition.

    More can be found at https://developer.opentext.com/apis/3a7bfdae-4cd3-465c-8485-c887f65def9b/bb4a87a8-62f4-4f81-a16e-2a258e7a51f1?action=search.

  • Change

    		headers.add("Authorization", "Basic "+"<<client-id>>:<<client-secret>>");
    

    with

    		headers.add("Authorization", "Baerer "+"<access_token>");
    


    Parag Doshi
    Senior Technical Architect | Enterprise Content Division
    Email: doship@opentext.com
    Blog: www.ecmnotes.com

  • Thank you!

    yes, post getting the auth token it was working fine. Now, we are facing the below challenge where we are unable to sync OTDS and Documentum repositories.

    We were able to create users using the OTDS API through JAVA code. Now we need to consolidate the same users between the OTDS and MEDS repository. When we try to consolidate using the below API (https://otds.medsdev.merck.com/otdsws/rest/consolidation/missinguser), getting the 403 error (unauthorized).  User which users to sync has all the admin roles in otds. Please request you to advise on this.

  • Hi Balaji,

    Can you post the code on how you were able to get the access token and then use it for subsequent REST API calls?

    Thank you,

    Hari