我正在通过来自Dynamics的插件在自定义实体上的字段更改时触发Webhook。 Webhook在正确的情况下被命中,但是请求正文为空。这是我的功能:
namespace UAM.Webhook.Functions
{
[DependencyInjectionConfig(typeof(DIConfig))]
public static class BulkLibraryAssetTransfer
{
[FunctionName("BulkLibraryAssetTransfer")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function,"get", "post", Route = null)]HttpRequestMessage req,
ILogger log, [Inject] IDynamicsHelper dynamicsHelper)
{
log.LogInformation("Beginning BulkLibraryAssetTransfer");
string reqBody = await req.Content.ReadAsStringAsync();
//var remoteContext = GetRemoteExecutionContextFromJson(reqBody);
log.LogInformation(reqBody);
//return req.CreateResponse(HttpStatusCode.OK);
var svc = dynamicsHelper.GetDynamicsSvc();
var input = JObject.Parse(reqBody);
Guid transferId = Guid.Parse(input["PrimaryEntityId"].ToString());
Entity transfer = svc.Retrieve("uam_transfer", transferId, new ColumnSet(true));
//log.LogInformation(transferId.ToString());
bool hasFailures = false, hasSuccesses = false;
IFlushingOperationLog logger = null;
Execute(logger, svc, transfer, ref hasSuccesses, ref hasFailures, log);
return req.CreateResponse(HttpStatusCode.OK);
}
}
}
在上面,“ reqBody”的日志返回{"body":""}
,因此,当我尝试解析任何响应时,其余代码将失败。我设置了另一个可以正常工作的函数,它在这里返回了一堆信息,例如BusinessUnitId,InitiatingUserId以及50多个其他字段。如果有人能指出我正确的方向,那就太好了。