World-Check-One API Authorisation using C#

Options

Hello,

Does anyone have any code snippets for performing API Authorisation using C# and the Built-in HttpClient classes?

I have tried an implementation based on the Postman examples, but all I am getting via my calls is a 401, while the equivilant in Postman works perfectly fine.

Best Answer

  • kamil.cisewski
    Answer ✓

    Hello @john.crocker

    thank
    you for the data. As we discussed the sample data you've provided looks
    correct. The only problem was with value of the signature.

    Easiest way to test it is to:
    - comment dateToSign variable in Postman pre-request script
    - create new variable using the data generated by your code, i.e.

    var dateToSign = "(request-target): get
    /v1/reference/countries\nhost:
    rms-world-check-one-api-pilot.thomsonreuters.com\ndate: Mon, 26 Sep 2016
    15:36:42 GMT";
    - send the request using postman
    - compare your signature with signature generated by the code

    From my experience algorithm to generate signature should looks like:
    - encode secret to sequence of bytes
    - encode message to sequence of bytes
    - create new instance of the HMACSHA256 class using the encoded secret
    - compute hash from the encoded message
    - convert result to base 64 string

    In the internet you can find many examples of the algorithm in the different programming languages.

Answers