简体   繁体   English

将 MSCRM.SuppressDuplicateDetection 标头添加到 CRM Dynamics Web API 请求会提供 HTTP 412 代码

[英]Adding MSCRM.SuppressDuplicateDetection header to CRM Dynamics Web API request gives HTTP 412 code

We are using the WEB API of Microsoft CRM Dynamics online (v9.0)我们使用的是Microsoft CRM Dynamics online (v9.0)的WEB API

Everything works fine with 'normal' create en read operations but when we want to use the duplication detection feature, the Microsoft webservice returns with 412.使用“正常”创建读取操作一切正常,但是当我们想要使用重复检测功能时,Microsoft Web 服务返回 412。

URL obj = new URL(fullOdataURL);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");

con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Authorization", "Bearer " + accesstoken);
con.setRequestProperty("OData-MaxVersion", "4.0");
con.setRequestProperty("OData-Version", "4.0");
con.setRequestProperty("MSCRM.SuppressDuplicateDetection", "false");

In the CRM web UI, the duplicate detection works, see screenshot在 CRM Web UI 中,重复检测工作,见截图

在此处输入图片说明

The HyperText Transfer Protocol (HTTP) 412 Precondition Failed client error response code indicates that access to the target resource has been denied.超文本传输​​协议 (HTTP) 412 Precondition Failed客户端错误响应代码表示对目标资源的访问已被拒绝。 This happens with conditional requests on methods other than GET or HEAD when the condition defined by the If-Unmodified-Since or If-None-Match headers is not fulfilled.If-Unmodified-Since满足If-Unmodified-SinceIf-None-Match标头定义的条件时,对GETHEAD以外的方法的条件请求会发生这种情况。 In that case, the request, usually an upload or a modification of a resource, cannot be made and this error response is sent back.在这种情况下,请求(通常是资源的上传或修改)将无法进行,并且会发回此错误响应。

Reference参考

So, in your request add this below header:因此,在您的请求中添加以下标头:

If-None-Match: null

Documentation 文档

con.setRequestProperty("If-None-Match", null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM