Azure APIM - 我如何 Request/POST。我想阻止某些字符并允许几个?

Azure APIM - How can I Request/POST. I want to block certain characters and allow few?

Azure APIM - 我如何 Request/POST。我想阻止某些字符并允许传入一些字符 POST?

<set-body>@(context.Request.Body.As<string>(preserveContent: true))</set-body>

我的政策中有以上一行,需要对其进行解析/迭代以仅允许 's and block all other (') 组合

您可以使用多行语法来实现更复杂的逻辑:

<set-body>@{
    var body = context.Request.Body.As<string>(preserveContent: true);
    body = body.Replace("'", string.Empty);
    return body;
}</set-body>

但如果只是更换,您需要查看我们的查找和更换政策 - 上面的示例效率更高。