0
votes

I am executing one SSIS package. I am trying to call one web api from that package.

My code:

IList<ESignDocumentServiceResponse> responseCollection = null;
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(url);
HttpResponseMessage response = httpClient.GetAsync($"api/abc").Result;
responseCollection = response.Content.ReadAsAsync<IList<DocumentServiceResponse>>().Result;

But i am getting an error at line ReadAsAsync as

"Error: Download failed: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

I have already added System.net.http.formatting in the project. But i am not sure why am i getting this error when i run this project.

2

2 Answers

0
votes

Whenever I have a NuGet error such as these I usually take these steps:

  1. Go to the packages folder in the Windows Explorer and delete it.
  2. Open Visual Studio and Go to Tools > Library Package Manager > Package Manager Settings and under the Package Manager item on the left hand side there is a "Clear Package Cache" button. Click this button and make sure that the check box for "Allow NuGet to download missing packages during build" is checked.
  3. Clean the solution
  4. Then right click the solution in the Solution Explorer and enable NuGet Package Restore
  5. Build the solution Taking all of these steps almost always restores all the packages and dll's I need for my MVC program.
0
votes

Similar problem. I used Nuget to install "System.Net.Http.Formatting.Extension" version="5.2.3.0" This resolved the issue for me.