You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Azure OpenAI Ingestion Job API返回404资源未找到求助

问题描述

我按照Azure官方文档使用Ingestion Job API,但不管怎么调整请求体或请求头里的api-key,服务器始终返回{ error: { code: '404', message: 'Resource not found' } }。我用的是Azure门户里Azure OpenAI资源→资源管理→密钥和终结点页面的终结点,资源部署在瑞典中部区域。请求代码如下:

const jobId = 'testing2793619'; // 要创建的作业ID

const url = `${openaiEndpoint}/openai/ingestion/jobs/${jobId}?api-version=2024-07-01-preview`;

const requestBody = {
    kind: "SystemCompute",
    searchServiceConnection: {
        kind: "EndpointWithKey",
        endpoint: searchEndpoint, // 替换为你的Azure AI Search服务终结点
        key: searchAdminApiKey // 替换为你的Azure AI Search管理员API密钥
    },
    datasource: {
        kind: "Storage", 
        connection: {
            kind: "ConnectionString",
            connectionString: blobStorageConnectionString
        },
        containerName: "testcontainer",
        chunking: {
            maxChunkSizeInTokens: 2048 // 根据需要自定义
        }
    },
    dataRefreshIntervalInHours: 24, // 根据需要自定义
    completionAction: "cleanUpTempAssets" // 根据需求选择,可选值包括"cleanUpTempAssets"
};

try {
    const response = await fetch(url, {
        method: 'PUT',
        headers: {
            'Content-Type': 'application/json',
            'api-key': openaiApiKey
        },
        body: JSON.stringify(requestBody)
    });

    if (response.ok) {
        const data = await response.json();
        console.log('请求成功:', data);
        return data;
    } else {
        const errorData = await response.json();
        console.error('Ingestion请求失败:', errorData);
    }
} catch (error) {
    console.error('错误:', error);
}
排查与解决建议
  • 检查终结点格式是否正确
    确认openaiEndpoint是完整的URL,正确格式应为https://<你的资源名称>.openai.azure.com/,注意末尾的斜杠不能少,避免拼接URL时出现路径断层。

  • 验证API版本的区域支持性
    确认瑞典中部区域是否开放了2024-07-01-preview版本的Ingestion Job API。部分预览版API仅在特定区域提供服务,可登录Azure门户查看该资源的API版本支持清单。

  • 核对资源状态与密钥有效性
    确认你的Azure OpenAI资源处于正常运行状态,没有被暂停或删除。同时检查使用的api-key是否属于该资源的有效密钥,别混用了其他Azure资源的密钥。

  • 检查请求路径与HTTP方法
    确认请求路径严格匹配API规范:{endpoint}/openai/ingestion/jobs/{jobId}?api-version={version},且HTTP方法为PUT,注意大小写不能出错。

  • 排查网络与防火墙限制
    检查发起请求的环境是否能正常访问Azure服务,有没有防火墙、代理规则阻止了请求。可以尝试在Azure门户的资源页面直接测试API连接,或用curl工具发起请求排查网络问题。

内容的提问来源于stack exchange,提问作者Max Claesson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 17:04:56