Forge Data和View API损坏,不再上传大文件

时间:2016-10-18 12:22:06

标签: c# rest authentication autodesk autodesk-forge

我一直在使用View和Data API一段时间来查看autodesk内容。最近,在认证版本发生变化之后,我似乎无法上传我的伊丽莎白皇后医院模型。

我是否需要迁移到v2才能继续像以前那样继续运行,因为我现在可以管理的是连续尝试上传后的7.5兆字节文件?

1 个答案:

答案 0 :(得分:0)

您要求代码,所以在这里,我将此代码升级到版本 v2 ,我不再获得令牌了。我认为这使我无法继续使用我正在使用的弃用版本。  版本下面的#note是v1,这可行!

    public static string Authenticate()
    {
        // (1) Build request 
        var client = new RestClient();
        client.BaseUrl = new System.Uri(baseApiUrl);

        // Set resource/end point
        var request = new RestRequest();
        request.Resource = "authentication/v1/authenticate";
        request.Method = Method.POST;

        // Set required parameters 
        request.AddParameter("client_id", consumerKey);
        request.AddParameter("client_secret", consumerSecret);
        request.AddParameter("grant_type", "client_credentials");
        request.AddParameter("scope", "data:read data:create data:write bucket:read bucket:create");


        // (2) Execute request and get response
        IRestResponse response = client.Execute(request);

        // Save response. This is to see the response for our learning.
        m_lastResponse = response;

        // Get the access token. 
        string accessToken = "";
        if (response.StatusCode == HttpStatusCode.OK)
        {
            JsonDeserializer deserial = new JsonDeserializer();
            Share_Model_OSSClasses loginResponse = deserial.Deserialize<Share_Model_OSSClasses>(response);
            accessToken = loginResponse.access_token;
        }

        return accessToken;
    }



public class Share_Model_OSSClasses
{
    public string token_type { get; set; }
    public string expires_in { get; set; } // expiry time in seconds. (30 min) 
    public string access_token { get; set; }
}