Error CS012 The call is ambiguous between the following methods or properties

In this azure tutorial, we will discuss how to fix the Error CS012 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 the Visual Studio 2019.

Error CS012 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 was 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

Error CS012 The call is ambiguous between the following methods or properties

Below was 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:\Users\Bijay\source\repos\deletesplistvs\deletesplistvs\Function1.cs

You can see it here

Error CS012 The call is ambiguous between the following methods or properties

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

To fix this issue, I have uninstalled the following Nuget package which i have 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.

Error CS012 The call is ambiguous between the following methods or properties: 'System.Net.Http.HttpRequestMessageExtensions.CreateResponse

You can find out the above nuget package and click on the Uninstall button

The call is ambiguous between the following methods or properties

Now click on the I Accept button to accept the License

Error CS012 The call is ambiguous between the following methods or properties: 'System.Net.Http.HttpRequestMessageExtensions.CreateResponse

After that you will not get any error

Error CS012 The call is ambiguous between the following methods or properties: 'System.Net.Http.HttpRequestMessageExtensions

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

This is how you can fix the Error CS012 The call is ambiguous between the following methods or properties

You may also like following the below articles

Wrapping Up

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

Leave a Comment