我有Web api端点
[HttpPut]
public async Task<IHttpActionResult> Rights(
[FromBody] IEnumerable<Rights> rights,
[FromBody] IEnumerable<Permissions> permissions)
任何想法我如何在请求的正文中传递这两个数组参数。我的代码是这样的
public static async Task Request(this RequestData requestData, Context context)
{
var url = requestData.GetAbsoluteUrl();
byte[] body = Encoding.UTF8.GetBytes(Serialize(requestData.Body, requestData.Body.GetType()));
using (var client = new CustomWebClient(context, body))
{
client.Headers.Add("Content-Type", "application/json");
await client.UploadAsync(url, requestData.Method.ToString(), body);
}
}
答案 0 :(得分:1)
public class RequestBody
{
public IEnumerable<Rights> rights
public IEnumerable<Permissions> permissions
}
将此类对象发送为RequestData