Coder Social home page Coder Social logo

autodesk-forge / forge-api-dotnet-client Goto Github PK

View Code? Open in Web Editor NEW
94.0 29.0 70.0 20.46 MB

Forge .Net SDK: Provides .Net SDK to help you easily integrate Forge REST APIs into the application

Home Page: https://www.nuget.org/packages/Autodesk.Forge/

License: Apache License 2.0

Batchfile 0.13% Shell 0.10% C# 99.77%

forge-api-dotnet-client's Introduction

forge-api-dotnet-client's People

Contributors

arrotech avatar astuy avatar augustogoncalves avatar cyrillef avatar czwangxtt avatar dukedhx avatar fredriklrsn avatar gregra81 avatar jaylimboonkiat avatar jmiller-pwi avatar khaleb85 avatar kimekeunkyung avatar lounsbrough avatar ltoni90 avatar petrbroz avatar rahulbhobe avatar shayneham avatar spark-developer avatar yiskang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forge-api-dotnet-client's Issues

HubsApi: cannot access EMEA hubs

I'm currently working on an integration with BIM360 Document Management and Revit software. This requires me to specify which datacenter is being accessed, and where the files are located to be downloaded.

With the current version of the Autodesk.Forge package, I'm correctly doing all the steps necessary in order to access the files necessary for the project, successfully so at that, but exclusively from the US datacenter. When trying to execute v1/hubs/ in an external tool such as Postman, the following metadata comes along, whilst providing at least one US-based hub:

"meta": {
  "warnings": [
    {
      "Id": null,
      "HttpStatusCode": "403",
      "ErrorCode": "BIM360DM_ERROR",
      "Title": "Unable to get hubs from BIM360DM EMEA.",
      "Detail": "You don't have permission to access this API",
      "AboutLink": null,
      "Source": [],
      "meta": []
    }
  ]
}

I'm using a three-legged token with the scopes data:read data:write data:create, and the application is provisioned by the BIM360 Account Admin. I'm currently out of ideas. Is there anything the Autodesk.Forge package can provide? Or am I looking in the wrong place?

locked temp folder item

Hi,
When I try to download an item using ObjectApi.GetObjectAsync method the item downloads successfully with the first request sent. however the next request to the same object gets stocked due to a file lock in temp folder in appdata\local\temp folder.
is there any what to release the file?
thanks
Afshin

MissingMethodException with RestSharp 106.5.0

System.MissingMethodException
   Method not found: 'Void RestSharp.RestRequest..ctor(System.String, RestSharp.Method)'.
      at Autodesk.Forge.Client.ApiClient.PrepareRequest(String path, Method method, Dictionary`2 queryParams, Object postBody, Dictionary`2 headerParams, Dictionary`2 formParams, Dictionary`2 fileParams, Dictionary`2 pathParams, String contentType)
      at Autodesk.Forge.Client.ApiClient.CallApi(String path, Method method, Dictionary`2 queryParams, Object postBody, Dictionary`2 headerParams, Dictionary`2 formParams, Dictionary`2 fileParams, Dictionary`2 pathParams, String contentType)
      at Autodesk.Forge.TwoLeggedApi.AuthenticateWithHttpInfo(String clientId, String clientSecret, String grantType, Scope[] scope)
      at Autodesk.Forge.TwoLeggedApi.Authenticate(String clientId, String clientSecret, String grantType, Scope[] scope)

The same error occurred when updating RestSharp to 106.5.2

deserialization not implemented?

Hi,
Although the documentation suggests to use classes as the outputs for API methods it seems it is not fully implemented:
/* Manifest */ dynamic GetManifest (string urn, string acceptEncoding = null);

any time frame on when these are ready?
thanks and regards,
Afshin

Can't translate DWG to SVF for Autodesk Viewer

Hello,
I'm using your Forge SDK for C# nuget, latest version.

I'm trying to get AutoDesk Viewer working for my app.
I've went all through Bucket creation, UploadModel and it seems that it works fine (I got the URN and so).

Following your tutorials, once I upload the model (DWG), I need to translate it to svf.
When using the Translate API, the request sent successfully, but when I send the manifest (via PostMan for that case), it's always in failed state. (For the same file that works completely ok with Autodesk online viewer).

I'm totally out of ideas.
Will appreciate some help.

            "name": "Bottom plate8.dwg",
            "hasThumbnail": "false",
            "status": "failed",
            "progress": "complete",
            "messages": [
                {
                    "type": "error",
                    "code": "AutoCAD-InvalidFile",
                    "message": "Sorry, the drawing file is invalid and cannot be viewed. \n- Please try to recover the file in AutoCAD, and upload it again to view."
                },
                {
                    "type": "error",
                    "message": "Unrecoverable exit code from extractor: -1073741831",
                    "code": "TranslationWorker-InternalFailure"
                }
            ],
            "outputType": "svf"

Let me know what type of info do you need and I will provide it.

Autodesk.Forge.dll is not generated when building the project

I use the forge-api-dotnet-client to access the forge web api. In my code I am using "Autodesk.Forge" and I have installed and added the forge-api-dotnet-client as a dependency. When building the project, the Autodesk.Forge.dll is not generated which results in an error when accessing the functionality provided.

Bug in .NET core proxies

I've experienced some issues when using this library for developping a proxy via Web Api .NET Core 2.2 :
Autodesk.Viewing.endpoint.setEndpointAndApi(${EnpointApiUrl}/api/forge, 'modelDerivativeV2');

Hope thoses issues will be fixed in next release.

  1. First error was produced in DerivativesApi when using GetManifestAsyncWithHttpInfo and GetDerivativeManifestAsyncWithHttpInfo.

To fix that, some little modification in ApiClient / Deserailize as

  • actual coding :
if (asType) return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
    return new DynamicJsonResponse(JObject.Parse(response.Content));
  • need to be fixed by :
 if (type == typeof(Manifest))
    return JObject.Parse(response.Content);
 if (type == typeof(BucketObjects))
   return new DynamicJsonResponse(JObject.Parse(response.Content));
  else
   return new DynamicJsonResponse(JObject.Parse(response.Content));
  1. Bug found when downloading in DerivativesApi / GetDerivativeManifestAsyncWithHttpInfo
 return new ApiResponse<Object>(localVarStatusCode,
               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
               **localVarResponse.RawBytes**); // null is not good here !
  1. Bug number 9 (no views) and to avoid array with integer indexes when rendering to json as 0: {...}, need to fix in DanamicJsonResponse by adding this:
       internal static void ProcessObjectArrayToList(JObject obj, DynamicDictionary dict)
        {
            foreach (KeyValuePair<string, JToken> pair in obj)
            {
                if (pair.Value.GetType() == typeof(JValue))
                {
                    dict.Dictionary[pair.Key] = ((JValue)pair.Value).Value;
                }
                else if (pair.Value.GetType() == typeof(JObject))
                {
                    DynamicDictionary subDict = new DynamicDictionary();
                    ProcessObject((JObject)(pair.Value), subDict);
                    dict.Dictionary[pair.Key] = subDict;
                }
                else if (pair.Value.GetType() == typeof(JArray))
                {
                    //DPN
                    //DynamicDictionary subDict =new DynamicDictionary () ;
                    var subDict = new List<dynamic>();
                    ProcessArrayToList((JArray)(pair.Value), subDict);
                    dict.Dictionary[pair.Key] = subDict;
                }
            }
        }

       internal static void ProcessArrayToList(JArray obj, List<dynamic> dict)
        {
            int i = 0;
            foreach (JToken item in obj)
            {
                if (item.GetType() == typeof(JValue))
                {
                    //dict.Dictionary [i.ToString ()] =((JValue)item).Value ;
                    dict.Add(((JValue)item).Value);
                }
                else if (item.GetType() == typeof(JObject))
                {
                    DynamicDictionary subDict = new DynamicDictionary();
                    ProcessObject((JObject)(item), subDict);
                    //dict.Dictionary [i.ToString ()] =subDict ;
                    dict.Add(subDict);
                }
                else if (item.GetType() == typeof(JArray))
                {
                    //DynamicDictionary subDict =new DynamicDictionary ();
                    var subDict = new List<dynamic>();
                    ProcessArrayToList((JArray)item, subDict);
                    //dict.Dictionary [i.ToString ()] =subDict ;
                    dict.Add(subDict);
                }
                i++;
            }
        }

Thank you for your awesome work !
Max.

Autodesk.Forge.Model.DesignAutomation.v3 ForgeAppsApi

Hi there,

I have been working around Autodesk.Forge.Model.DesignAutomation.v3 and found a few issues:

ForgeAppsApi.ForgeAppsGetNickname("me") is returning a quoted string. Quotes needs to be removed before you can get the Application NickName you are looking for.

ForgeAppsApi.ForgeAppsDeleteUser("me"); is a long process as stated in https://forge.autodesk.com/en/docs/design-automation/v3/reference/http/forgeapps-id-DELETE/. Is there a Way to know when the Api is able to process a new request ?
I'm working around at the moment with a Try Catch in a Do While Loop until the following request succeeds.

Bug by translating SVF to OBJ - JobObjOutputPayloadAdvanced; ObjectIds - List<int> not List<string>

The ObjectIds in the object Autodesk.Forge.Model.JobObjOutputPayloadAdvanced have to be declared as List not List

https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/

curl -X 'POST' -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: Bearer PtnrvrtSRpWwUi3407QhgvqdUVKL' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' -d
'{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LnppcA"
},
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "obj",
"advanced": {
"modelGuid": "4f981e94-8241-4eaf-b08b-cd337c6b8b1f",
"objectIds": [
2,
3,
4
]

}
}
]
}
}'

Update .NET 4.6 support

We are need to update our visual studio licenses, but we are not able because the .NET SDK Forge only supports .NET4.0

`content-type` hard coded

, it would be nice to be able to set ‘Content-Type’ via your API, otherwise we’re forced to use RestSharp. In your API for ‘UploadChunkAsyncWithHttpInfo()’ the content-type is hard-coded to ‘application/octet-stream’, but we’re using RestSharp to account

TwoLeggedApi: AuthenticateAsync never ends

I have a project that implements the basic forge features. This project is shared between two solutions, but in one solution the project works normally, in the other one doesn't work, when it call the AuthenticateAsync function it doesn't recive any result.

this is the code:
image

both the solutions have Autodesk.Forge 1.6.0, Newtonsoft.Json 12.0.2 and RestSharp 106.11.4

Thanks.

Bug by translating SVF to OBJ - GetDerivativeManifestWithHttpInfo does not return the result data

        // make the HTTP request
        IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
            Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
            localVarPathParams, localVarHttpContentType);

        int localVarStatusCode = (int) localVarResponse.StatusCode;

        if (ExceptionFactory != null)
        {
            Exception exception = ExceptionFactory("GetDerivativeManifest", localVarResponse);
            if (exception != null) throw exception;
        }

--------------------- ISSUE HERE: ApiResponse.Data cannot be null...----------------------

       return new ApiResponse<Object>(localVarStatusCode,
            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
      null); 

Streams not handled properly on ObjectApis.UploadObjectXXX methods

ObjectApis.UploadObject and ObjectApis.UploadObjectAsync fail for certain types of streams. We are using the following WebApi code (some parts omitted) and it crashes:

MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync<MultipartMemoryStreamProvider>(new MultipartMemoryStreamProvider());

foreach (HttpContent content in provider.Contents)
{
     var stream = await content.ReadAsStreamAsync();
     dynamic uploadedObj = await objects.UploadObjectAsync(fileStoreBucket, item.Id, (int)stream.Length, stream, "application/octet-stream");
}

We have tracked it down to the following code in ObjectsApi.cs which does not seem to be handling streams properly:

 if (body != null && body.GetType() == typeof(byte[])) // http body (model) parameter
            {
                localVarPostBody = body; // byte array
            }
            else if (   body != null
                     && (   body.GetType() == typeof(System.IO.FileStream)
                         || body.GetType() == typeof(System.IO.BinaryReader)
                         || body.GetType() == typeof(System.IO.BufferedStream)
                   	     || body.GetType() == typeof(System.IO.MemoryStream)
                   	     || body.GetType() == typeof(System.IO.StreamReader)
                   	    )
                    )
            {
                localVarPostBody = Configuration.ApiClient.toByteArray(body); // byte array
            }
            else if ( body != null )
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body);
            }

We have created a quick fix in a local build, but it would be nice to be able to use the official NuGet library. The fix is simply replacing the above code with this:

localVarPostBody = Configuration.ApiClient.toByteArray(body); // byte array

We can submit a pull request if needed.

FoldersApi.PostFolderAsync missing parameters

I'm using the following to create a new folder:

    [HttpPost]
    [Route("api/forge/folders/newFolder")]
    public async Task<bool> PostNewFolder([FromBody]NewFolder newFolder)
    {
      FoldersApi foldersApi = new FoldersApi();
      foldersApi.Configuration.AccessToken = AccessToken;

      CreateFolder createFolder = new CreateFolder(
        new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0),
        new CreateFolderData(
          new CreateFolderDataAttributes(newFolder.Name,
          new BaseAttributesExtensionObjectWithoutSchemaLink("folders:autodesk.core:Folder", "1.0", null)),
          new CreateFolderDataRelationships(
            new CreateFolderDataRelationshipsParent(
              new CreateFolderDataRelationshipsParentData(
                new ResourceId())))));

      await foldersApi.PostFolderAsync(newFolder.ProjectId, createFolder);

      return true;
    }

    public class NewFolder
    {
      [JsonProperty("parentFolderId")]
      public string ParentFolderHref { get; set; }

      public string ProjectId
      {
        get
        {
          string[] hrefParams = ParentFolderHref.Split('/');
          return hrefParams[hrefParams.Length - 3];
        }
      }

      public string FolderId
      {
        get
        {
          string[] hrefParams = ParentFolderHref.Split('/');
          return hrefParams[hrefParams.Length - 1];
        }
      }

      [JsonProperty("folderName")]
      public string Name { get; set; }
    }

This produces a JSON body:

{
   "jsonapi":{
      "version":"1.0"
   },
   "data":{
      "attributes":{
         "name":"New folder",
         "extension":{
            "type":"folders:autodesk.core:Folder",
            "version":"1.0"
         }
      },
      "relationships":{
         "parent":{
            "data":{
               "id":{

               }
            }
         }
      }
   }
}

Which is missing information, like data.type and a way to fill relationships.parent.data.type & id

The correct should be:

{
    jsonapi: {
      version: "1.0"
    },
    data: {
      type: "folders",
      attributes: {
        name: "new folder,
        extension: {
          type: "folders:autodesk.core:Folder",
          version: "1.0"
        }
      },
      relationships: {
        parent: {
          data: {
            type: "folders",
            id: "xxxxxxparentfolderidxxxxx"
          }
        }
      }
    }
  }
}

.net core support

Does this library support .net core ? if not when will we be able to use this sdk with .net core.

the API only supported limited Filter types, can't flexible to support more filter types.

Forge-DM does have a filtering feature and documented here https://developer.autodesk.com/en/docs/data/v2/overview/filtering/ , but these API including GetHubProjects, GetHubs, GetFolderContents .etc are only supported limited filter types, for example, https://developer.api.autodesk.com/project/v1/hubs/b.a3d23eec-****-b932-fe63ecee08c3/projects?filter[name]=My Project are supported, but can not be supported by the .NET API.
I have checked with engineer, https://developer.autodesk.com/en/docs/data/v2/reference/http/hubs-hub_id-projects-GET/ is not correct about filter types, and more filter types can be supported without a problem.

How to delete folder from A360

Using FoldersApi to remove a folder from the A360, the folder is not deleted. How can I delete a folder from the A360 using this client

Autodesk.Forge.Model.DesignAutomation.v3 NicknameRecord

Hi again,

Here is the Workaround i mentioned in my previous post:

        private void TrySetNickName(string nickName)
        {
            PublicKey key = new PublicKey(new byte[0], new byte[0]);
            NicknameRecord nick = new NicknameRecord(nickName, key);

            bool failed;
            do
            {
                try
                {
                    failed = false;
                    Console.WriteLine("Trying to Set NickName ...");
                    forgeAppsApi.ForgeAppsCreateNickname("me", nick);
                }
                catch (Exception)
                {
                    Console.WriteLine("Attempt Failed");
                    failed = true;
                }

            } while (failed);
        }

This time it's just a request:
Is it possible to set an empty PublicKey in NicknameRecord(string Nickname) ctor ?
This empty PublicKey is needed ForgeAppsApi.ForgeAppsCreateNickname("me", nick); call.

And a question:
What is this PublicKey suppose to do in the future (I coudn't find any information on it) ?

GetObject queries

Hi, I have 2 queries:
1- Trying to download a Revit project about 10MB takes about 1 min when using GetObject. downloading the same file directly from BIM 360 takes less than 5 secs. is there any reason why GetObject takes so long?
2- When downloading a relatively large Revit project using GetObject I get an OutOfMemoryException. So I try to use the range parameter to split the file into multiple chunks and then merge it back which seems to work. I just wanted to confirm if this is the right way to do it.

Thanks for the great work btw.

Add support for Webhooks

Hi Team,

There are two customers are asking the possibility to add support for Forge MD Webhooks via Zendesk(case id: 2271 & 2328). Please take times to consider the possibility, thank you!

"The limit value is invalid." error

I'm trying to use GetFolderContents api as per below (in C#):
var folderItems = foldersApi.GetFolderContents(projectId, folderId, filterType: new List<string>() { "items" }, pageLimit: 1000);

but I'm getting below error:
Error calling GetFolderContents: { "jsonapi": { "version": "1.0" }, "errors": [{ "id": "6ffd7c96-0c44-4223-8fa2-713bd02a548a", "status": "400", "code": "BAD_INPUT", "title": "One or more input values in the request were bad", "detail": "The limit value is invalid." } ] }

I am using v1.5 of the Forge dll from nuget btw

Use PKCE for 3-legged Auth

Whenever you develop a native app (i.e. desktop app), we face the problem of storing the secret key. OAuth 2 specifications recommends using PKCE for this type of apps as in this link and this.

Is there any plans to implement this scenario in Forge?

Thanks,

Implement ApiClient Retry

Would be nice if your API had retry logic baked in. There are some scenarios (i.e., network timeouts) where a retry would eliminate false failures. Perhaps wrap the RestSharp.Execute() in retry logic (2 or 3 retries). We are doing this in our handrolled RestSharp implementation if you'd like a sample.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.