我正在开发一个使用其余API的Xamarin表单共享的应用程序,到目前为止唯一的问题是,由于某些原因,当我尝试发布新评论时,它不会出现在网站平台中
public async Task<String> SendCommentAsync(Commentary comment, String id)
{
String credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:admin"));
String Reply = "";
Uri url = new Uri(string.Format("http://wordpresswebsite.com/wp-json/wp/v2/comments"+"?post="+id+ "&author_name="+ comment.UserName + "&Authentication=" + credentials + "&content=" + comment.Content + "&parent=" + comment.Parent, string.Empty));
Console.WriteLine("url : " + url);
HttpContent content = new StringContent("", Encoding.UTF8, "application/json");
try
{
//POST resquest
HttpResponseMessage response = await client.PostAsync(url,content);
Reply = response.StatusCode.ToString();
String StrContent = await response.Content.ReadAsStringAsync();
Console.WriteLine("Content Return : " + StrContent );
}
catch (Exception ex)
{
Debug.WriteLine(@" ERROR {0}", ex.Message);
}
return Reply;
}
}
这是状态为OK的响应:
[]
我还尝试使用Postman来测试请求,但http://wordpresswebsite.com/wp-json/wp/v2/comments?author_name=SpartaName&content=comment&authorization=20am9hb2FscG9pbTpqb2FvNjE0MzUy&post=59
也是如此我必须包含任何强制性参数,或者我的请求本身是否有问题?