Click here to Skip to main content
15,745,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public string Execute(string url, DataSet dsItem)
                using (HttpClient client = new HttpClient())
                    client.BaseAddress = new Uri(url);
                        new MediaTypeWithQualityHeaderValue("application/json"));

                    DataRow gXITEMrow = dsItem.Tables[0].Rows[0];

                    GXITEM gXITEM = new GXITEM();

                    gXITEM.GXID = new Guid();
                    if (gXITEMrow["GXREVNUM"]!=DBNull.Value)
                        gXITEM.GXREVNUM = Convert.ToInt32(gXITEMrow["GXREVNUM"]);
                    if (gXITEMrow["GXCODE"] != DBNull.Value)
                        gXITEM.GXCODE = Convert.ToString(gXITEMrow["GXCODE"]);
                    var postTask = client.PostAsJsonAsync<GXITEM>("api/GXITEMs/gXITEM", gXITEM);

                    var result = postTask.Result;

This is my client code trying to call my WebApi using am HttpClient
My problem is that I get a runtime error when I am calling the API: could not load file or assembly although the specified assembly is referenced in my client project.I have added the NuGet package Microsoft.AspNet.WebApi.Client 5.2.7. What can be wrong?

What I have tried:

uninstalled and installed the nugget package

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900