The call is ambiguous between the following methods or properties

In this Azure tutorial, we will discuss how to fix the Error the call is ambiguous between the following methods or properties: This error I got after executing the Azure Function Code to interact with the SharePoint From Azure Function to delete a SharePoint list using Visual Studio 2019.

The call is ambiguous between the following methods or properties

Recently, I was trying to write an Azure Function code to interact with SharePoint to delete a SharePoint List using the Visual Studio 2019 IDE. I got this error.

Below is my Azure Function code

[FunctionName("NewFunction")]
        public static async Task<HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage request,
            ILogger log)
        {

            string site = "https://tsinfo.sharepoint.com/sites/SPFx/";
            string userName = "ASE@tsinfo.onmicrosoft.com";
            string password = "#####@12345";

            // parse query parameter  
            string listtitle = request.GetQueryNameValuePairs()
                .FirstOrDefault(q => string.Compare(q.Key, "title", true) == 0)
                .Value;


            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char ch in password)
            {
                secureString.AppendChar(ch);
            }

            SharePointOnlineCredentials creds = new SharePointOnlineCredentials(userName, secureString);

            using (var ctx = new ClientContext(site))
            {
                ctx.Credentials = creds;
                List lst = ctx.Web.Lists.GetByTitle(listtitle);
                lst.DeleteObject();
                ctx.ExecuteQuery();
                return lst == null
                ? request.CreateResponse(HttpStatusCode.BadRequest, "Error retreiveing the list")
                : request.CreateResponse(HttpStatusCode.OK, "ListDeleted successfully " + listtitle);
            }
            return null;
        }
    }

When I started executing the code, I got the below error

The call is ambiguous between the following methods or properties:

Below is the exact error message that I got,

Error CS012 The call is ambiguous between the following methods or properties: ‘System.Net.Http.HttpRequestMessageExtensions.CreateResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, T)’ and ‘System.Net.Http.HttpRequestMessageExtensions.CreateResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, T)’ deletesplistvs C:UsersBijaysourcereposdeletesplistvsdeletesplistvsFunction1.cs

You can see it here

the call is ambiguous between the following methods

The call is ambiguous between the following methods or properties [Solved]

To fix this issue, I have uninstalled the following Nuget package, which I installed earlier that I don’t need now.

Microsoft.AspNetCore.Mvc.WebApiCompatShim

You need to right-click on the Project and click on the Manage NuGet Packages.

the call is ambiguous between the following methods or properties:

You can find the above Nuget package and click on the Uninstall button

the call is ambiguous between the following methods or properties entity framework

Now click on the I Accept button to accept the License

httprequestmessageextensions

After that, you will not get any error

the call is ambiguous between the following methods or properties: 'datarowassertionextensions.should<tdatarow>(tdatarow)' and 'datasetassertionextensions.should<tdataset>(tdataset)'

Try uninstalling the unnecessary NuGet packages that you might have installed, and you are not using them.

This is how you can fix error cs0121: the call is ambiguous between the following methods or properties.

You may also like following the articles below

Wrapping Up

Well, in this article, we discussed how to fix the error the call is ambiguous between the following methods. Hope it will help you to fix your issue as well !!!