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

Autodesk Forge下载PDF视图报错:请求的资源不存在

问题:调用APS Model Derivative签名Cookie接口返回「资源不存在」错误

接口与参数

  • 请求接口:GET /modelderivative/v2/designdata/:urn/manifest/:derivativeUrn/signedcookies
  • 使用参数:
    • 主URN: urn:adsk.wipprod:fs.file:*************?version=23
    • 衍生文件URN: urn:adsk.viewing:fs.file:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkNTRmdGWWZqUlotRHV2cThEd3R3WFE_dmVyc2lvbj0yMw/output/Resource/Plano de planta/Planta Baja-Locales Comerciales 2287883/pdf/Planta Baja-Locales Comerciales.pdf

代码实现

const { accessToken, urn } = req.body;
const configADSK = {
  headers: {
    Authorization: `Bearer ${accessToken}`,
  },
};
// 获取Manifest
const response = await axios.get(
  `${baseUrl}/modelderivative/v2/designdata/${btoa(urn).replace("/", "_").replace("=", "")}/manifest`,
  configADSK
);

let derivatives = response.data.derivatives[0].children; // 索引0为主衍生文件,索引1为缩略图

// 筛选2D视图
let pdfViews = derivatives.filter(
  (v) => v.role == "2d" && !!v.properties["Print Setting"]
);

// 过滤缩略图
let pdfDerivatives = pdfViews.map((v) => v.children.find((d) => d.role == "pdf-page"));
pdfDerivatives = pdfDerivatives.filter((dv) => dv !== undefined);

// 获取Revit版本
const rvtVersion = response.data.derivatives[0].properties["Document Information"].RVTVersion;

// 获取签名Cookie(下载链接)
let downloadUrls = [];
let options = {
  method: "GET",
  headers: {
    Authorization: "Bearer " + accessToken,
  },
};
for (const derivative of pdfDerivatives) {
  let url = `https://developer.api.autodesk.com/modelderivative/v2/designdata/${urn}/manifest/${derivative.urn}/signedcookies?useCdn=true`;

  let resp = await fetch(url, options);
  let respJSON = await resp.json();
  downloadUrls.push(respJSON);
}

res.json(downloadUrls);

错误响应

{
  "developerMessage": "The requested resource does not exist.",
  "moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/",
  "errorCode": ""
}

已尝试操作

参考官方指引实现,曾猜测文件名空格导致问题,将空格替换为%20后问题仍存在。


解决建议

  • 统一主URN的编码格式:调用签名Cookie接口时,主URN需要和获取Manifest时保持一致——对原始主URN执行btoa(urn).replace("/", "_").replace("=", "")处理,生成URL安全的Base64编码后再拼接到URL路径中,不能直接使用原始URN。
  • 完整编码衍生文件URN:衍生文件URN包含斜杠、空格等特殊字符,需使用encodeURIComponent()对其进行完整URL编码,而非仅替换空格为%20。
  • 验证衍生文件URN的有效性:打印pdfDerivatives数组,确认每个元素的urn取值是否与Manifest中记录的PDF衍生文件URN完全一致,避免筛选逻辑错误导致传入无效URN。
  • 检查Token权限:确保请求使用的Access Token包含data:read权限,权限不足也可能返回「资源不存在」的错误。
  • 尝试禁用CDN:临时去掉URL中的?useCdn=true参数,直接从源站请求,排除CDN节点未同步衍生文件的可能。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 14:12:33