XeroAPI / Xero-NetStandard

A wrapper of the Xero API in the .NetStandard 2.0 framework. Supports Accounting, Payroll AU/US, and Files
MIT License
120 stars 119 forks source link

Method not found: RestSharp.RestRequestExtensions.AddFile #442

Closed Yahya0007 closed 6 months ago

Yahya0007 commented 1 year ago

SDK you're using (please complete the following information):

Describe the bug apiInstance.GetInvoicesAsync(xeroToken.AccessToken, xeroTenantId,, where) was working fie but recently has stopped working with below exception;

`- ex {"Method not found: 'RestSharp.RestRequest RestSharp.RestRequestExtensions.AddFile(RestSharp.RestRequest, System.String, Byte[], System.String, System.String)'."} System.Exception {System.MissingMethodException} ClassName Nothing String

To Reproduce Call apiInstance.GetInvoicesAsync(xeroToken.AccessToken, xeroTenantId,, where)

RettBehrens commented 1 year ago

Hi @Yahya0007 we recently released an update that included upgrading from 106.12.0 to 108.0.1.

I just just tested GetInvoicesAsync using our sample app running the latest SDK and was unable to replicate the issue locally.

Even though I'm unable to replicate using the sample app I do believe the issue stems from this update. Is there anything in #439 that stands out to you?

Abhisha1 commented 1 year ago

Hi @Yahya0007

Just following up on this issue, it might be that the mismatch of the RestSharp versions may be the issue here as we are using 108.0.1 but you are using 108.0.2.

As we are unable to replicate this, if you are still facing this issue when you use RestSharp version 108.0.1, could you try put together a minimal project that replicates the issue (without including your client id/secret ) and share it with us. This would be helpful in trying to solve what is causing the issue you face given we cannot reproduce the issue. Thanks

Yahya0007 commented 1 year ago

Hi

When we use 108.0.1 then it says error loading 108.0.2.

Regards

Yahya

From: Abhisha @.> Sent: 26/09/2022 23:35 To: XeroAPI/Xero-NetStandard @.> Cc: Yahya0007 @.>; Mention @.> Subject: Re: [XeroAPI/Xero-NetStandard] Method not found: RestSharp.RestRequestExtensions.AddFile (Issue #442)

Hi @Yahya0007 https://github.com/Yahya0007

Just following up on this issue, it might be that the mismatch of the RestSharp versions may be the issue here as we are using 108.0.1 but you are using 108.0.2.

As we are unable to replicate this, if you are still facing this issue when you use RestSharp version 108.0.1, could you try put together a minimal project that replicates the issue (without including your client id/secret ) and share it with us. This would be helpful in trying to solve what is causing the issue you face given we cannot reproduce the issue. Thanks

— Reply to this email directly, view it on GitHub https://github.com/XeroAPI/Xero-NetStandard/issues/442#issuecomment-1258723568 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBRRP4ECX2PBJ3GRCNMBNLWAIQKZANCNFSM6AAAAAAQUJFLY4 . You are receiving this because you were mentioned.Message ID: @.***>

Abhisha1 commented 1 year ago

hi @Yahya0007 Thanks for letting me know. In that case, is it possible for you to spin up a minimal project without your secrets that replicates this issue? I have tried again and still cannot reproduce this particular issue here so creating a project would be really helpful.

Abhisha1 commented 1 year ago

Hi @Yahya0007 Just wanted to follow up on this issue. Were you able to recreate the issue in a small project?

If not, could you perhaps provide the package references used in your project. There may be a mismatch of RestSharp versions that might be causing the issue.

Thanks

Yahya0007 commented 1 year ago

Hi Abhisha

The project is large and intertwined so hard to turn into a small project. References in the project with Xero code attached.

Thanks

Regards

Yahya

From: Abhisha @.> Sent: 03/10/2022 00:47 To: XeroAPI/Xero-NetStandard @.> Cc: Yahya0007 @.>; Mention @.> Subject: Re: [XeroAPI/Xero-NetStandard] Method not found: RestSharp.RestRequestExtensions.AddFile (Issue #442)

Hi @Yahya0007 https://github.com/Yahya0007 Just wanted to follow up on this issue. Were you able to recreate the issue in a small project?

If not, could you perhaps provide the package references used in your project. There may be a mismatch of RestSharp versions that might be causing the issue.

Thanks

— Reply to this email directly, view it on GitHub https://github.com/XeroAPI/Xero-NetStandard/issues/442#issuecomment-1264766334 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBRRP32IPQ6VX73XXBAY4TWBINHRANCNFSM6AAAAAAQUJFLY4 . You are receiving this because you were mentioned.Message ID: @.***>

<Reference Include="DevExpress.Data.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.ExpressApp.ConditionalAppearance.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.ExpressApp.Security.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.ExpressApp.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.ExpressApp.Win.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.ExpressApp.Security.Xpo.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.ExpressApp.Xpo.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Map.v21.2.Core, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Persistent.Base.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Persistent.BaseImpl.Xpo.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Printing.v21.2.Core, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Data.Desktop.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Utils.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpo.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraEditors.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraMap.v21.2, Version=21.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="IdentityModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=e7877f4675df049f, processorArchitecture=MSIL">
  <HintPath>..\packages\IdentityModel.6.0.0\lib\net472\IdentityModel.dll</HintPath>
</Reference>
<Reference Include="Json.Net, Version=1.0.33.1, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Json.Net.1.0.33\lib\netstandard2.0\Json.Net.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes, Version=1.9.0.0, Culture=neutral, PublicKeyToken=ee75fc290dbc1176, processorArchitecture=MSIL">
  <HintPath>..\packages\JsonSubTypes.1.9.0\lib\net47\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="KellermanSoftware.Compare-NET-Objects, Version=4.78.0.0, Culture=neutral, PublicKeyToken=d970ace04cc85217, processorArchitecture=MSIL">
  <HintPath>..\packages\CompareNETObjects.4.78.0\lib\net48\KellermanSoftware.Compare-NET-Objects.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.WebServices.Auth, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.Auth.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=6.23.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.IdentityModel.Abstractions.6.23.1\lib\net472\Microsoft.IdentityModel.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=6.23.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.6.23.1\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=6.23.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.IdentityModel.Logging.6.23.1\lib\net472\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=6.23.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.IdentityModel.Tokens.6.23.1\lib\net472\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="NCalc, Version=1.3.8.0, Culture=neutral, PublicKeyToken=973cde3f1cafed03, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>.\NCalc.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=108.0.2.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
  <HintPath>..\packages\RestSharp.108.0.2\lib\netstandard2.0\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=6.23.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\System.IdentityModel.Tokens.Jwt.6.23.1\lib\net472\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Net.Http.Json.6.0.0\lib\net461\System.Net.Http.Json.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=6.0.0.6, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="Xero.NetStandard.OAuth2, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Xero.NetStandard.OAuth2.3.28.1\lib\netstandard2.0\Xero.NetStandard.OAuth2.dll</HintPath>
</Reference>
<Reference Include="Xero.NetStandard.OAuth2Client, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Xero.NetStandard.OAuth2Client.1.6.0\lib\netstandard2.0\Xero.NetStandard.OAuth2Client.dll</HintPath>
</Reference>
Abhisha1 commented 1 year ago

Thanks @Yahya0007.

I also was able to trigger the error you were seeing when I added a reference to RestSharp version 108.0.2 like <PackageReference Include="RestSharp" Version="108.0.2" /> in the sample app.

When I changed this to reference version 108.0.1, as the Net Standard SDK does, the error was gone and the endpoints worked as intended. I had a look into this further and found the missing method exception can be raised when there are different versions of a library used in the same project.

Therefore, to resolve the error, please update your RestSharp reference to version 108.0.1 and run dotnet clean and then dotnet build. This should remove any lingering references in the dll to other versions and the endpoint should work as expected.

CyanideMonkey commented 1 year ago

Ola! Is there any word on if Xero will be updated to work with any newer versions of RestSharp than 108.1? I had RestSharp 110.2 in my project (which is the latest) so I was glad to find this workaround, but it would be good to not be concerned about if any references get updated at some point. Thanks!