我需要发送 multipart / mixed 请求以执行某些操作,并且端点支持 multipart / mixed 内容类型,该内容类型支持application / json和application / xml。
>当我尝试使用Restsharp如下发送请求时,内容类型在提琴手中以Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
的形式传递,并以415 -UNSUPPORTED MEDIA TYPE
的形式得到响应
代码:
RestRequest req = new RestRequest(endpoint, Method.POST)
{
AlwaysMultipartFormData = true
};
if (!string.IsNullOrEmpty(bearerToken))
{
req.AddHeader("Authorization", string.Format("Bearer {0}", bearerToken));
}
req.AddHeader("Content-Type", "mulitpart/mixed");
req.AddHeader("Content-Type", "application/json");
req.AddParameter("processTypeCreationMetadata", "<JSON Request>");
req.AddHeader("Content-Type", "application/xml");
req.AddParameter("processBpmnDefinition", <xml Request Content>);
var res = _client.Execute(req);
return res.Content;