Search code examples
autodesk-forgeautodesk-model-derivative

Why am I not getting all the data in the manifest?


I have a successfully loaded and converted model, but I also need to extract the manifest. Unfortunately, when I extract the manifest, I do not get it entirely. I need to get the entire manifest. I tried to solve the problem by recursively calling the function that receives the manifest, but in any case I did not get the manifest completely. I would like to know what is the reason why a recursively called function also does not receive a manifest and how else can this problem be solved.

function getManifest(getToken, urn) {
  return new Promise(async (resolve, reject) => {
    const baseUrl = "https://developer.api.autodesk.com";
    const url = `${baseUrl}/modelderivative/v2/designdata/${urn}/manifest`;
    const token = typeof getToken == "function" ? await getToken() : getToken;

    const fetch = () =>
      request(
        {
          url,
          method: "GET",
          headers: {
            Authorization: token,
            "Content-Type": "application/json",
            Accept: "application/json",
          },
          json: true,
        },
        async (err, response, body) => {
          if (err) {
            return reject(err);
          }

          if (body && body.errors) {
            return reject(body.errors);
          }

          if (body.progress !== "complete") {
            await require("util").promisify(setTimeout)(3000);
            return fetch();
          }

          if ([200, 201, 202].indexOf(response.statusCode) < 0) {
            return reject(response);
          }

          return resolve(body || {});
        },
      );

    return fetch();
  });
}

enter image description here


Solution

  • When a translation job is posted, it takes time(depends on file size) for translation to be complete.

    If you want to get manifest as soon as the translation is 100% complete, use this webhook api and mention workflowid in post job like shown here.

    For webhook url in development mode you can use ngrok