Trying to execute this request, but getting null response data with response code 500:
var insightlyService = new InsightlyService();
var response = insightlyService
.With<Contact>(true)
.GetAll();
var contacts = response.ResponseData();
I managed to narrow it down to the creation of the FlurlClient in InsightlyService.Authorise, where the return object is not being cast to FlurlClient.
Original
public FlurlClient Authorise(string path)
{
var request = InsightlyUri + path;
return request.WithBasicAuth(ApiKey, "");
}
Error in VS
Cannot implicitly convert type 'Flurl.Http.IFlurlClient' to 'Flurl.Http.FlurlClient'. An explicit conversion exists (are you missing a cast?)
First Change
So I updated the code to look like this:
public IFlurlClient Authorise(string path)
{
var request = InsightlyUri + path;
var o = request.WithBasicAuth(ApiKey, "");
return o;
}
But now I am seeing an error on this line:
responseData = await response.ReceiveJson<T>().ConfigureAwait(false);
Exception
{"Request to https://api.insight.ly/v2.2/Contacts/ failed. JSON integer 100224663348 is too large or small for an Int32. Path '[0].CONTACTINFOS[0].CONTACT_INFO_ID', line 1, position 411."}
Second Change
I noticed that the encoded API Key in the header looks different to when I manually make this call from PowerShell (Maybe a problem with the base64 encoding?) So I tried adding it manually here like so:
public FlurlClient Authorise(string path)
{
var request = InsightlyUri + path;
var flurlClient = new FlurlClient(request);
flurlClient.WithHeader("Authorization", "Basic EncodedAPIKeyasperPowershellbase64Encoding");
return flurlClient;
}
But this resulted in the same error as above (request integer is too large), so it looks like the issue is happening in Flurlclient?
Trying to execute this request, but getting
nullresponse data with response code500:I managed to narrow it down to the creation of the
FlurlClientinInsightlyService.Authorise, where the return object is not being cast toFlurlClient.Original
Error in VS
First Change
So I updated the code to look like this:
But now I am seeing an error on this line:
Exception
Second Change
I noticed that the encoded API Key in the header looks different to when I manually make this call from PowerShell (Maybe a problem with the base64 encoding?) So I tried adding it manually here like so:
But this resulted in the same error as above (request integer is too large), so it looks like the issue is happening in
Flurlclient?