2016-05-17 72 views
0

我以前發佈this question關於如何從azure搜索中提取索引架構。獲取索引Azure搜索失敗'預檢的響應具有無效的HTTP狀態代碼403'

我能夠通過使用GET Index REST API使用郵差,沒有任何問題,但在瀏覽器中運行我的代碼時,我得到的錯誤拉的索引架構:

XMLHttpRequest cannot load https://[service name].search.windows.net/indexes/[index name]?api-version=[api-version] Response for preflight has invalid HTTP status code 403

我只是運行在控制檯以下代碼:

$.ajax({ url: 'https://[service name].search.windows.net/indexes/[index name]?api-version=[api-version]', type: 'GET', datatype: 'json', headers: {'api-key': [api-key]}})

然而,這個代碼工作正常(返回所有數據 - 唯一的區別是/docs):

$.ajax({ url: 'https://[service name].search.windows.net/indexes/[index name]/docs?api-version=[api-version]', type: 'GET', datatype: 'json', headers: {'api-key': [api-key]}})

另一個奇怪的是,對於GET請求指數請求頭不顯示API密鑰。

看起來像CORS(它在Azure搜索上設置爲'*'),不喜歡瀏覽器對GET索引的請求嗎?

任何幫助將受到歡迎。

+0

可能的重複[jQuery的Ajax - 從本地主機生成沒有'訪問控制允許來源'標頭](http://stackoverflow.com/questions/37127195/jquery-ajax-post-from-localhost-generates -no-access-control-allow-origin-hea) –

回答

3

Azure搜索不支持管理級別的操作,例如CORS請求中的獲取索引。見this related answer

+0

謝謝......那就是我一直在尋找的東西。 – chrissavage

相關問題