Last post Feb 06, 2021 03:25 PM by jjmbph
Jan 26, 2021 07:37 AM|jjmbph|LINK
Just need your guidance here. I need to access an API with Hmac authentication. I was able to successfully send a request GET/POST using Postman and .net Console app. But when I use the same code with asp.net mvc, it gives an Unauthorized response from the
API using a POSTASYNC. The same code working for GETASYNC request
I am generating the hmac using a secret key and json payload. This json which I also passed as HTTPContent. Here is the snippet of my post request.
string hmackey = CalculateHmac(key, PayLoad);
HttpResponseMessage response = new HttpResponseMessage();
using (var client = new HttpClient())
client.BaseAddress = new Uri(uri);
client.Timeout = new TimeSpan(100000000);
HttpContent content = new StringContent(PayLoad, Encoding.UTF8, "application/json");
response = await client.PostAsync(uri, content);
result = response.Content.ReadAsStringAsync().Result;
Jan 27, 2021 08:59 AM|Jerry Cai|LINK
Is this api from the third party? and no matter it's yours or the third party, you should follow the rules, make sure it needs that
and didn't miss the others.
How do you get the token. make sure they are still within the valid time.
And try to not use uri to send post , just use string instead to check whether the problems lies in the uri, it can work on postman but can't on
console, so you should check the differences, have you changed the code?
Feb 06, 2021 03:25 PM|jjmbph|LINK
I managed to call the api thru hmac using a RestSharp. This can be closed.