JRamsay022096 (Community Member) asked a question.

I'm using C# to access the results API. I'm able to call getapplist, but when I call detailedreport I get a 401 Error. It works fine when I use the VeracodeC#API wrapper in Powershell, but that is not an option here. Do anyone have any C# examples?

  • rmachado (Veracode, Inc.)

    Hello Jramsay,

     

    I believe that if you use HMAc to authenticate your request you will be able to complete the request. The example below should help you.

    https://help.veracode.com/r/c_enabling_hmac

     

    Regards,

    Rafael

    Expand Post
    Selected as Best
      • JRamsay022096 (Community Member)

        I've gone over the documentation. I'm able to pull the report via Powershell using the VeracodeC#API.exe wrapper. However, it requires that we specify a download folder and that is not an option.

    • JRamsay022096 (Community Member)

      Thank you for your reply, I will verify the role and permissions.

  • JRamsay022096 (Community Member)

    Thank you for the suggestion. roles and permissions are verified. While I still receive a 401 when I use webClient.DownloadString(), webClient.DownloadData() is working, returning bytes.

     

    string ApiId = "xxxxxxx";

    string ApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

    string urlBase = "analysiscenter.veracode.com";

    string urlPath = "/api/5.0/detailedreport.do";

    var urlParams = "?build_id=xxxxxxx";

    const string httpVerb = "GET";

     

    var webClient = new WebClient

    {

        BaseAddress = $"https://{urlBase}"

    };

     

    var authorization = HmacAuthHeader.HmacSha256.CalculateAuthorizationHeader(ApiId, ApiKey, urlBase, urlPath, urlParams, httpVerb);

     

    webClient.Headers.Add(AuthorizationHeader, authorization);

    var downloadUrl= "https://" + urlBase + urlPath + urlParams;

     

    var result = webClient.DownloadData(downloadUrl);

    string download = Encoding.ASCII.GetString(result);

     

    XmlDocument xml = new XmlDocument();

    xml.LoadXml(download);

     

    Expand Post
  • rmachado (Veracode, Inc.)

    Hello Jramsay,

     

    I believe that if you use HMAc to authenticate your request you will be able to complete the request. The example below should help you.

    https://help.veracode.com/r/c_enabling_hmac

     

    Regards,

    Rafael

    Expand Post
    Selected as Best

Topics (1)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.