autodeskautodesk-model-derivative

Response headers are not available


I try to download PDF 2D view from Revit model. I use this Documentation and this Blog post.

But i cannot get 'Set-Cookie' headers in response body using code from Blog post or code below.

export const getPDFSheet = async (urn: string, derivativeUrn: string) => {
  const response = await autodeskInstanceDownload.get(
    `/modelderivative/v2/designdata/${urn}/manifest/${derivativeUrn}/signedcookies?useCdn=true`,
  );
  console.log('response', response.headers);
};

response.headers in code above doesn't contain any 'set-cookie' headers.

Please advise what i do wrong? The first thing i do is simply copy code from blog, but headers are not available in response.


Solution

  • It could be related to the HTTP client library you used. (i.e. autodeskInstanceDownload.get). In addition, there is not a query string parameter for this endpoint called useCdn.

    //index.js
    
    const axios = require('axios');
    
    let urn = ...;
    let derivativeUrn = ...;
    let encodedDerivativeUrn = encodeURIComponent( derivativeUrn );
    
    let config = {
      method: 'get',
      maxBodyLength: Infinity,
      url: 'https://developer.api.autodesk.com//modelderivative/v2/designdata/${urn}/manifest/${encodedDerivativeUrn}/signedcookies',
      headers: { 
        'Authorization': 'Bearer ....', 
        'Content-Type': 'application/json'
      }
    };
    
    axios.request(config)
    .then((response) => {
      console.log(JSON.stringify(response.headers));
      console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
      console.log(error);
    });
    
    

    Here is the test result using axios:

    enter image description here