I want to convert rvt file into ifc file. For that I am using autodesk forge API.
Firstly I have created app on autodesk and after that creating token with below code:-
const response = await
fetch('https://developer.api.autodesk.com/authentication/v2/token',
{
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
"client_id": "myclientid",
"client_secret": "myclientscert",
"grant_type": 'client_credentials',
"scope": 'bucket:create bucket:read data:write data:read'
}),
});
After that I have created a bucket with below code:-
fetch('https://developer.api.autodesk.com/oss/v2/buckets', {
method: 'POST',
headers: {
Authorization: `Bearer ${data.access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
bucketKey: bucketKey,
policyKey: 'persistent'
})
});
const bucket = await bucketresponse.json();
bucket is also created but When I am going to upload my rvt file then I am getting error like:
Status: 403 Forbidden ReasonPhrase: Forbidden "reason":"Legacy endpoint is deprecated
I am using below code to uplaod file.
using (FileStream stream = new FileStream("D:\\Tech.rvt", FileMode.Open, FileAccess.Read))
{
var content = new StreamContent(stream);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var request = new HttpRequestMessage(HttpMethod.Put,
$"https://developer.api.autodesk.com/oss/v2/buckets/{bucket}/objects/{Uri.EscapeDataString(fileName)}");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Content = content;
var response = await httpClient.PutAsync(request);
var result = await response.Content.ReadAsStringAsync();
}
Getting same error on Postman as well.
Please let me know What I am missing?
