改装 REST 库 - 无法发布列表;在体内
我无法通过改装发布列表。这是接口声明:
[Post("/api/Url/{id}")]
[Headers("Content-Type:application/json")]
Task<Model> PostMethod([Body(BodySerializationMethod.UrlEncoded)] CommandType command)
这是 CommandType 类
public class CommandType
{
public IEnumerable<Guid> Prop { get; set; }
}
尽管 Refit 能够进行调用,但 Prop 的参数在接收端为 null。
[更新] 我也尝试过 [Body(BodySerializationMethod.UrlEncoded)] [Query(CollectionFormat.Multi)] 但没有运气!
[找到的解决方案] 我已经通过删除 Body 属性和 CommandType 使用以下方法解决了这个问题。相反,直接将类内部的属性放入参数中。仅供参考。
[Query(CollectionFormat.Multi)] Guid 的 IEnumerable for Prop
I'm unable to post List through refit. Here's the interface declaration:
[Post("/api/Url/{id}")]
[Headers("Content-Type:application/json")]
Task<Model> PostMethod([Body(BodySerializationMethod.UrlEncoded)] CommandType command)
Here's the CommandType class
public class CommandType
{
public IEnumerable<Guid> Prop { get; set; }
}
Even though Refit is able to make the call but the argument for Prop is null at the receiving end.
[UPDATE] I tried with [Body(BodySerializationMethod.UrlEncoded)] [Query(CollectionFormat.Multi)] too but no luck!
[FOUND SOLUTION] I've solved it using just the following by removing both Body attribute and CommandType. Instead, put the Property inside the class into the parameter directly. Just FYI.
[Query(CollectionFormat.Multi)] IEnumerable of Guid for Prop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论