Test Data Manager

  • 1.  How to Get security token to use REST API's

    Posted Jan 11, 2018 09:05 AM

    Hi 

    I have a scenario to automate publishing the data without even opening the TDM portal.

    I followed the steps as per the link here Use APIs to Prepare Test Data for Non-Relational Sources - CA Test Data Manager - 4.2 - CA Technologies Documentation 

    I used my credential to get an encoded value and with that encoded value, I tried to generate a token with help of this  link https://<server>:<port>/TestDataManager/swagger-ui.html where-in I replaced the server and port with appropriate values. After which when I try to generate the token I always end up with error 401 "Unauthorized user ".

     

    How do I generate the token for using the REST API's

     

    Thanks and regards

    Prashanth

     

     



  • 2.  Re: How to Get security token to use REST API's

    Posted Jan 11, 2018 09:29 AM

    Hi Prasanth, 

     

    Here is the documentation on how to generate a token for REST APIs:

    Get the Security Token

    Use the login API to log in and generate a security token. You use your CA TDM Portal login credentials to generate the security token. You can then use the same security token to perform all other operations. The security token remains valid for 24 hours.
    For more information about how to get a security token, see the "Get a Security Token" section in "Use APIs to Design and Consume Automated Test Data Services".

    Use APIs to Manage Environments - CA Test Data Manager - 4.4 - CA Technologies Documentation 

    Get a Security Token

    The process to get a security token involves two steps:

    1. Encode your CA TDM Portal credentials to the Base64 format.
    2. Use the encoded value in a POST request to generate a security token.

    The security token remains valid for 24 hours.

    Use APIs to Prepare Test Data for Non-Relational Sources - CA Test Data Manager - 4.4 - CA Technologies Documentation 

    Get the Security Token

    Use the login API to log in and generate a security token. You use your CA TDM Portal login credentials to generate the security token. You can then use the same security token to perform all other operations. The security token remains valid for 24 hours.

    Follow these steps:

    1. Access an application that allows you to encode your credentials to the Base64 format.
    2. Enter your CA TDM Portal login credentials (in the format <user name>:<password>) in the source field.
      Note: Ensure that the credentials have appropriate permissions to perform all the required operations.
    3. Click the option to encode the credentials. The encoded Base64 format for the example is displayed as follows:

      ZwRTaX5pc4SxYXSvcjptYXJtaXRl
    4. Copy the encoded value.
    5. Access the following CA TDM Portal API:

      Note: For more information about this API, see the "auth-controller: Auth Controller" section at https://<server>:<port>/TestDataManager/swagger-ui.html. For the example in this article, the URL is https://server-po:8443/TestDataManager/swagger-ui.html.

    6. Enter the encoded value in the Authorization field, which is as follows for the example:

      Basic YWRtaW5pc3RyYXRvcjptYXJtaXRl
    7. Run the API to get a security token for your credentials.
    8. Note the value of the token parameter in the response body, which is as follows for the example:

      eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBZG1pbmlU0VSX0lEBTExfUFJPSkVDVFNcIjpbMTAwXX0ifQ.7T1CyH_xQK0vQcBB7dLojUxm8ENTeRRrdOa-RQ5l4Ro

      You have successfully generated a security token that you can use in all the subsequent operations explained in this article.

    Use APIs to Manage Test Data Models - CA Test Data Manager - 4.4 - CA Technologies Documentation 

     

    If you are still having issues, please open a support case by going to http://www.ca.com/us/services-support/ca-support/contact-support.html



  • 3.  Re: How to Get security token to use REST API's

    Posted Jan 11, 2018 09:41 AM

    I already followed these steps before posting the question. Is there something that my login credentials needs to have access to generate the token, If so who provides he access.  



  • 4.  Re: How to Get security token to use REST API's

    Posted Jan 11, 2018 10:02 AM

    I think the documentation may be a little scarce and missing some steps then.

     

    How did you test this URL? 

    You need to send some extra informations at the Header, so TDM can give you a security token.

    I use Postman to work with REST API's: Postman | Supercharge your API workflow 

    Postman works great to test POST methods.

     

    How are you calling REST API?

    Please ensure you have the correct format as specified in the Swagger API

    I believe its REST GET call. 

    Also, the security token use to authenticate is valid 24 hours, so you have  call API again to get a new Security Token after expired.

     

    Try using swagger-ui that comes out of the box.

    https://hostname:port/TestDataManager/swagger-ui.html

     

    Ensure that the backend is working properly
    If Self-signed SSL certificates are being blocked:
    Fix this by turning off 'SSL certificate verification' in Settings > General
    If Client certificates are required for this server:
    Fix this by adding client certificates in Settings > Certificates
    If Request timeout:
    Change request timeout in Settings > General

    By default SSL certificate verification is turned on. File>Settings and flip it off.

    When getting your token from Postman, remember to READ the message at the side of the authorization field in Swagger. Postman just gives you the token. Swagger needs Bearer ****** (token) otherwise it doesn't work.

     

     

    barra11, litda06, Peter.DeZutter, sanar03- are you able to help Prashanth?

     

     

    I suggest opening a support case by going to http://www.ca.com/us/services-support/ca-support/contact-support.html



  • 5.  Re: How to Get security token to use REST API's
    Best Answer

    Posted Jan 11, 2018 10:32 AM

    Prashanth18,

    I'm sharing a POSTMAN Collection with some REST examples you can try. There is one for Login:

    https://www.getpostman.com/collections/1cf005bbac2071c27dee 

     

    Can you try it, following these steps bellow, to check if it's possible to generate a Token?

    1: Change the URL to your TDM portal server.

    2: At Authorization use Basic Auth, (3)

    3: Type your Username and Password

    4: Update request. This will regenerate an encoded Base64 Authorization attribute at Headers

     

    Push the Send button and let us know what happens.

     

    Best Regards,

    Artur



  • 6.  Re: How to Get security token to use REST API's

    Broadcom Employee
    Posted Jan 11, 2018 10:19 AM

    Hi Prashanth,

     

    Are you using an AD user or a TDM Native user?

    Has the user group been granted wit the REST Function?

     

    Also try using Postman to do the login, it also saves you from doing the Base64 encoding, you can find the Postman collection hereTDM API - Postman collection. , ready to be imported in Postman..

     

    Best regards,

    Peter



  • 7.  Re: How to Get security token to use REST API's

    Posted Jan 12, 2018 04:25 AM

    Thank you for the support from all the above three post, I got the security Token generated