I have the follwoing code. Written in a c# library refernce in my x project.
public async Task FetchRef(PayloadModel model, string apiKey, string url)
{
try
{
string hashValue = "xxxxxx"
var authorization = $"Bearer {hashValue}";
var resps =await url
.WithHeader("Authorization", authorization)
.PostJsonAsync(model)
.ReceiveString();
var jsonResult = resps.Replace("jsonp (", "")
.Replace(")", "");
var response = JsonConvert.DeserializeObject(jsonResult);
if (response == null)
throw new Exception("Invalid Remita response");
if (!string.IsNullOrEmpty(response.statusCode) && response.statusCode.Equals("025"))
{
return response;
}
else
{
throw new Exception(response.statusMessage);
}
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
Calling this code form x returns an error that the object am accessing is a Task and not the object i was expecting.
How can i achieve this. Thanks