2016-07-29 10 views
1

Create an App-Managed Bucket and Upload a Fileに記載されているようにバケットを作成しようとしています。私は、コマンドボックスにカールを使用する場合、それは良い作品:Autodesk-model-derivative:バケットの作成:リモートサーバーからエラーが返されました:(400)Bad Request

curl 
-v "https://developer.api.autodesk.com/oss/v2/buckets" 
-X "POST" 
-H "Content-Type: application/json" 
-H "Authorization: Bearer ObfuscatedBucketCreateToken" 
-d "{"""bucketKey""":"""itx5""", """policyKey""":"""transient"""}" 

は、今私は、C#/ Visual Studioに同じことをしよう:request.getResponse(オン

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://developer.api.autodesk.com/oss/v2/buckets"); 
    request.Method = "POST"; 

    UTF8Encoding encoding = new UTF8Encoding(); 
    Byte[] byteArray = encoding.GetBytes(@"{""bucketKey"":""Itx7"", ""policyKey"":""transient""}"); 

    request.ContentLength = byteArray.Length; 
    request.ContentType = @"application/json"; 
    request.Headers.Add(@"Authorization: Bearer ObfuscatedBucketCreateToken"); 

    using (Stream dataStream = request.GetRequestStream()) 
    { 
     dataStream.Write(byteArray, 0, byteArray.Length); 
    } 

    using (HttpWebResponse webRresponse = (HttpWebResponse)request.GetResponse()) 
    { 
     long length = webRresponse.ContentLength; 
     using (Stream stream = webRresponse.GetResponseStream()) 
     { 
      // do your thing 
     } 
    } 

)私が手例外 "リモートサーバーがエラーを返しました:(400)Bad Request"。

私はOAthトークンを取得できますが、何とかバケットを作成しようとすると、常にこの例外が返されます。

なぜこの例外が発生しますか?なぜこの例外が発生するのかを調査する方法はありますか?

答えて

2

C#でテストするときにバケット名を大文字で指定したようです。 "" Itx7は "" APIヘルプは言う:

HTTP/1.1 **400** Bad Request 
    ...... 

    { 
    **"reason":"Valid field 'bucketKey' must be of the form [-_.a-z0-9]  
    {3,128}"** 
    } 

私たちはバケツにブログを持っています。説明のほとんどは、まだ新しいバージョンに適用されます。

http://adndevblog.typepad.com/cloud_and_mobile/2015/01/buckets-in-autodesk-view-and-data-api.html

は、これらが役立ちます願っています。トリックをした

よろしく、

暁東梁 フォージAdovater
開発者向け技術サービス
オートデスク

+0

はい、!ありがとうございました。 –