Sample code for consuming the Track-It! 2019 Web API

Version 1
    Share This:

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    Track-It!


    COMPONENT:

    Track-It! 2019 R3


    APPLIES TO:

    Track-It! 2019 R3



    QUESTION:

    How to consume the Web API for Track-It! 2019?


    ANSWER:

    The following link should give you knowledge on how to consume the Web API for Track-It! 2019.

    https://docs.bmc.com/docs/trackit2019/en/web-services-api-852581354.html

    Here is a sample code

    Use the following code snippet to correctly authenticate with the API:

    static void Main(string[] args)
            {
                HttpClient client = new HttpClient();

                client.BaseAddress = new Uri("http://localhost:4577/TrackItDev/WebApi/");
                var data = Encoding.UTF8.GetBytes($"scope=&grant_type=password&username=<GROUP\\USER>&password=<PWD>");

                using (MemoryStream ms = new MemoryStream(data))
                using (StreamContent content = new StreamContent(ms))
                {
                    var result = client.PostAsync("token", content).Result;
                    Debug.Assert(result.StatusCode == System.Net.HttpStatusCode.OK);
                }
            }


    Article Number:

    000174689


    Article Type:

    FAQ/Procedural



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles