1
我試圖按照Create an App-Managed Bucket and Upload a File中所述創建存儲桶。當我在命令框中使用捲曲,它的工作原理好:Autodesk-model-derivative:創建存儲桶:遠程服務器返回錯誤:(400)錯誤的請求
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#做同樣的/視覺工作室:
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
}
}
在request.getResponse()我得到「遠程服務器返回錯誤:(400)錯誤請求」異常。
我以類似的方式,我能夠獲得OAth令牌,但不知何故,當我嘗試創建一個存儲桶時,它總是返回此異常。
爲什麼我會得到這個異常?有沒有辦法來調查爲什麼我得到這個異常?
是的,這確實的伎倆!謝謝。 –