- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello for everyone,
I am trying to convert DWG Files to DXF Files, i am using ODA File Converter, but i wanna use AUTODESK API for this convert, i have this code now but not working.
/ Função para obter o token de acesso
async function getAccessToken() {
const response = await axios.post('https://developer.api.autodesk.com/authentication/v1/authenticate', {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'client_credentials',
scope: 'data:read data:write data:create bucket:create bucket:read',
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
return response.data.access_token;
}
// Função para converter DWG para DXF
async function convertDWGtoDXF(dwgFile) {
const accessToken = await getAccessToken();
const response = await axios.post('https://developer.api.autodesk.com/modelderivative/v2/designdata/job', {
input: {
urn: dwgFile,
},
output: {
formats: [
{
type: 'dxf',
views: ['2d'],
},
],
},
}, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});
return response.data;
}
Solved! Go to Solution.
Link copied