Method not found: 'Void RestSharp.RestRequest..ctor(RestSharp.Method)'.
Xero.Netstandard.OAuth2.Client - 1.6 Xero.Netstandard.OAuth2 - 3.29
Resthsharp - 108. 0.1.0 Also tried with 108.0.2.0
Authorization is getting successful and later when try to create invoice using async method gets error
Method not found: 'Void RestSharp.RestRequest..ctor(RestSharp.Method)'.
Earlier used with Restsharp 106.X version, we didn't had any issue. Due to other features we have upgraded Restsharp later xero integration stopped working with above issue.
Sample Code below
In line var xeroResp = await AccountingApi.CreateInvoicesAsync(accessToken, t.TenantId.ToString(), objInvoices); // we get the issue.
public async Task
if (response.IsError)
{
strErrMsgLink = response.Error;
throw new Exception(response.Error);
}
var accessToken = response.AccessToken;
var refreshToken = response.RefreshToken;
var identityToken = response.IdentityToken;
string tenant;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
using (var requestMessage = new HttpRequestMessage(System.Net.Http.HttpMethod.Get, "https://api.xero.com/connections"))
{
HttpResponseMessage httpResult = client.SendAsync(requestMessage).Result;
System.Console.WriteLine(httpResult.RequestMessage);
tenant = httpResult.Content.ReadAsStringAsync().Result;
tenantList = JsonConvert.DeserializeObject<List<Tenant>>(tenant);
}
foreach (Tenant t in tenantList)
{
Invoices objInvoices = new Invoices();
List<Invoice> xinvoices = new List<Invoice>();
xinvoices.Add(PrepareInvoiceObj());
if (xinvoices.Count > 0)
{
objInvoices._Invoices = xinvoices;
var AccountingApi = new AccountingApi();
var xeroResp = await AccountingApi.CreateInvoicesAsync(accessToken, t.TenantId.ToString(), objInvoices); // Creating the Invoice In XERO
}
else
{
strErrMsgLink = "Xero Invoice object is empty";
break;
}
}
strErrMsgLink = string.Empty;
result = true;
}
}
catch (Exception ex)
{
Logging
}
return result;
}
Hi @pradeepinfotechi
I am taking a look and trying to reproduce this particular error. I haven't been able to yet but in the meantime, could I ask you to keep the version as 108.0.1 and try clear your nuget cache and re-running your project. Does the error persist?
dotnet nuget locals all --clear
dotnet clean
dotnet build
dotnet run