1

I have the following http get urn: https://developer.api.autodesk.com/modelderivative/v2/designdata/:urn/manifest/:derivativeUrn/signedcookies

with the following parameters:

urn: urn:adsk.wipprod:fs.file:*************?version=23

derivativeUrn: urn:adsk.viewing:fs.file:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkNTRmdGWWZqUlotRHV2cThEd3R3WFE_dmVyc2lvbj0yMw/output/Resource/Plano de planta/Planta Baja-Locales Comerciales 2287883/pdf/Planta Baja-Locales Comerciales.pdf

the endpoint docs: https://aps.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-manifest-derivativeUrn-signedcookies-GET/

my code:

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

let derivatives =
  response.data.derivatives[0].children; //the 0 is the main derivative, the index 1 comprise the thumbnails

//get 2d views
let pdfViews = derivatives.filter(
  (v) =>
    v.role == "2d" &&
    !!v.properties["Print Setting"]
);

//filter the thumbnails since they are also embedded here!!
let pdfDerivatives = pdfViews.map((v) =>
  v.children.find((d) => d.role == "pdf-page")
);
pdfDerivatives = pdfDerivatives.filter(
  (dv) => dv !== undefined
);

//revit version
const rvtVersion =
  response.data.derivatives[0].properties[
    "Document Information"
  ].RVTVersion;

//next step is to get the signedUrl!
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`; //?useCdn=true`;

  let resp = await fetch(url, options);

  let respJSON = await resp.json();
  downloadUrls.push(respJSON);
}

res.json(downloadUrls);

when sending the request, the response return:

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

I've followed the instructions from this blog: https://aps.autodesk.com/blog/download-your-revit-2d-views-pdfs

My intuition tells me that it might be related with the space characters between the pdf file name such as in "Planta Baja-Locales Comerciales" So I also tried replacing space characters with "20%" symbols to represent empty spaces in url domains. However, this didn't fix the issue

Any other suggestion??

1 Answer 1

1

My bad, it turns out that I forgot to encode the urn as following:

  let url = 
  https://developer.api.autodesk.com/modelderivative/v2/designdata/${btoa(
    urn
  )
    .replace("/", "_")
    .replaceAll("=", "")}/manifest/${
    derivative.urn
  }/signedcookies; 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.