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令牌,但不知何故,当我尝试创建一个存储桶时,它总是返回此异常。
为什么我会得到这个异常?有没有办法来调查为什么我得到这个异常?
是的,这确实的伎俩!谢谢。 –