2
當使用HTML Web資源加載Dynamics CRM表單時,我從Chrome瀏覽器控制檯收到以下錯誤消息。在Web資源上動態CRM Web API身份驗證錯誤
的https: //xxxx.api.crm6.dynamics.com/api/data/v8.2/ <自定義實體>。請求的資源上沒有「Access-Control-Allow-Origin」標題。原因'https://.crm6.dynamics.com'因此不被允許訪問。響應有HTTP狀態代碼401
<script type="text/javascript">
var clientUrl = "https://xxxx.api.crm6.dynamics.com/api/data/v8.2/"
function GetAccounts() {
var url = clientUrl + "accounts"
$.ajax({
method: "GET",
url: url,
async: false,
beforeSend: getAccountsBeforeSendCallback,
fail: getAccountsFailCallback,
done: getSavingGoalsDoneCallback,
success: getAccountsSuccessCallback
});
}
function getAccountsBeforeSendCallback(jqXHR, settings) {
debugger
jqXHR.setRequestHeader("OData-MaxVersion", "4.0");
jqXHR.setRequestHeader("OData-Version", "4.0");
jqXHR.setRequestHeader("Accept", "application/json");
jqXHR.setRequestHeader("Content-Type", "application/json; charset=utf-8");
}
</script>
大多數討論的主題都是一般的。 CORS和JSONP將做到這一點。 https://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource –