Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
方法不允许-Post REST API_Api_Rest_Post_Model View Controller_Routes - Fatal编程技术网

方法不允许-Post REST API

方法不允许-Post REST API,api,rest,post,model-view-controller,routes,Api,Rest,Post,Model View Controller,Routes,该API与GET配合良好,但不喜欢POST。这是我在控制器中的REST API POST函数 [HttpPost] public void Auth([FromBody] string username) { } 我从我的Xamarin应用程序中这样称呼它 using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://site

该API与GET配合良好,但不喜欢POST。这是我在控制器中的REST API POST函数

        [HttpPost]
        public void Auth([FromBody] string username)
        {

        }
我从我的Xamarin应用程序中这样称呼它

using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://siteurl");
var response = await client.PostAsync("/api/PCUsers", new {username = "test1"} , new JsonMediaTypeFormatter());
}
我不断得到“405方法不允许”。我想这和路线有关。有人能帮我吗

谢谢大家!