0

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.

enter image description here

Please let me know What I am missing?

1 Answer 1

0

You need to generate a signed URL to upload your file in the bucket.

You can follow the instructions from https://aps.autodesk.com/en/docs/data/v2/tutorials/upload-file/#step-4-generate-a-signed-s3-url

You can also find a .NET example using our SDK at https://github.com/autodesk-platform-services/aps-sdk-net/blob/main/samples/oss.cs#L41-L53

For the Model Derivative part (conversion to IFC), you can use the Model Derivative SDK, as done at https://github.com/autodesk-platform-services/aps-sdk-net/blob/main/samples/modelderivative.cs#L31-L93

You just need to change the payload according to the RVT->IFC options

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.