Azure APIM验证 - 包含入站政策,验证请求主体
我的API在APIM中,我需要验证请求有效负载主体(JSON格式),以提高要求。
我遵循了这个步骤 https://learlen.microsoft.com/en-en---en----我们/azure/api管理/验证 - 属性#属性
我已经在入站策略中添加了下面的策略,上述 schemaid 和上述创建的模式。
<validate-content unspecified-content-type-action="prevent" max-size="102400" size-exceeded-action="prevent" errors-variable-name="requestBodyValidation">
<content type="application/json" validate-as="json" action="detect" schema-id="Postschema" />
</validate-content>
即使遵循上述步骤,如果我对无效的JSON提出请求,我仍会收到200个成功响应。我想念什么?
I have api's in APIM, i need to validate request payload body(Json Format) foreach Post Request.
I followed steps from this
https://learn.microsoft.com/en-us/azure/api-management/validation-policies#attributes
I have added proper json schema in Schemas :-
and i have added below policy in Inbound policy, mentioned schemaid with the above created schema.
<validate-content unspecified-content-type-action="prevent" max-size="102400" size-exceeded-action="prevent" errors-variable-name="requestBodyValidation">
<content type="application/json" validate-as="json" action="detect" schema-id="Postschema" />
</validate-content>
Even after following above steps, if i make request with invalid json, i am still receiving 200 success response. What am i missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请将操作将操作更改为 forcorm-type application> application/json 。
您还可以将操作更改为
检测
未指定的content-type-action
,如果您想允许不带有content-type的请求application> application> application/json
。actions :
Please change the action
detect
toprevent
for content-typeapplication/json
.You can also change the action to
detect
forunspecified-content-type-action
if you want to allow requests without content-typeapplication/json
.Actions: