所以我最近在一个不同版本控制方案的新解决方案中重新构建了我的API和客户端。有些代码有变化,但与JsonServiceClient无关。无论如何,我收到此例外陈述405 Method Not Allowed Code: Method Not Allowed, Message: The requested resource does not support http method 'GET'.
问题是请求不是GET
而是POST
,我不确定它的混淆程度。实际帖子如下:
var result = (
await
webService.PostAsync(new Login
{
Token = token,
Provider = provider,
IsLinkedAccount = isLinkedAccount,
ResponseText = responseText,
Uuid = uuid,
Platform = platform
}))
Login
DTO表示为:
[Route("/login", "POST")]
public partial class Login
: IReturn<LoginDTO>
{
public virtual string Token { get; set; }
public virtual SocialNetworks Provider { get; set; }
public virtual string Email { get; set; }
public virtual bool IsLinkedAccount { get; set; }
public virtual string ResponseText { get; set; }
public virtual string Uuid { get; set; }
public virtual Platform Platform { get; set; }
}
实际的API路由表示如下:
public class LoginController : ApiController
{
[AcceptVerbs("POST")]
public async Task<LoginDTO> Login(Login request)
{
...
}
}
我已经使用招摇和邮递员来验证端点确实准确,我可以手动发送HTTP POST,那么是什么搞砸了JsonServiceClient?
这些是我使用
的服务堆栈版本<package id="ServiceStack.Client" version="4.0.52" targetFramework="net452"/>
<package id="ServiceStack.Common" version="4.0.52" targetFramework="net452"/>
<package id="ServiceStack.Interfaces" version="4.0.52" targetFramework="net452" />
<package id="ServiceStack.Text" version="4.0.52" targetFramework="net452" />