[英]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 thanGET
orHEAD
when the condition defined by theIf-Unmodified-Since
orIf-None-Match
headers is not fulfilled.当If-Unmodified-Since
满足If-Unmodified-Since
或If-None-Match
标头定义的条件时,对GET
或HEAD
以外的方法的条件请求会发生这种情况。 In that case, the request, usually an upload or a modification of a resource, cannot be made and this error response is sent back.在这种情况下,请求(通常是资源的上传或修改)将无法进行,并且会发回此错误响应。
So, in your request add this below header:因此,在您的请求中添加以下标头:
If-None-Match: null
con.setRequestProperty("If-None-Match", null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.