0

I have tried what was suggested in RestSharp: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0 and it didn't work for me. I am just trying to get it to work on my machine right now. I have installed RestSharp 110.2.0 and System.Text.Json 7.0.2 and I still get the following error:

FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

This is my code:

var options = new RestClientOptions("https://api.elliemae.com")
{
     MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/oauth2/v1/token", Method.Post);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("grant_type", "password");
request.AddParameter("username", encompass.userName);
request.AddParameter("password", encompass.password);
request.AddParameter("client_id", encompass.apiClientId);
request.AddParameter("client_secret", encompass.clientSecret);
RestResponse response = client.Execute(request);

I get the error when it tries to instantiate the client.

I have the PackageReference in place:

<ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
    <PackageReference Include="RestSharp" Version="110.2.0" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
    <PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

But still the error. Any other ideas?

I have tried everything I could find on here about it. My code listed above should get me an access token. And would if I were using RestSharp 106.12, but I would like to keep up to date on the libraries since this is on Azure.

  • Does this answer your question? [RestSharp: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0](https://stackoverflow.com/questions/76138571/restsharp-could-not-load-file-or-assembly-system-text-json-version-7-0-0-0) – Alexey Zimarev May 24 '23 at 14:02
  • It's a duplicate of https://stackoverflow.com/questions/76138571/restsharp-could-not-load-file-or-assembly-system-text-json-version-7-0-0-0 – Alexey Zimarev May 24 '23 at 14:02

0 Answers0