C# Autodesk model Derivation:创建存储桶:远程服务器返回错误:(400)请求错误
我正在尝试创建一个bucket,如中所述。在命令框中使用cURL时,效果很好:C# Autodesk model Derivation:创建存储桶:远程服务器返回错误:(400)请求错误,c#,autodesk-forge,autodesk-model-derivative,C#,Autodesk Forge,Autodesk Model Derivative,我正在尝试创建一个bucket,如中所述。在命令框中使用cURL时,效果很好: curl -v "https://developer.api.autodesk.com/oss/v2/buckets" -X "POST" -H "Content-Type: application/json" -H "Authorization: Bearer ObfuscatedBucketCreateToken" -d "{"""bucketKey""":"""itx5""", """policyKe
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执行同样的操作:
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)请求错误”
我使用类似的方法,可以获得誓言令牌,但不知何故,当我尝试创建一个bucket时,它总是返回此异常
为什么我会得到这个例外?有没有办法调查我为什么会出现这种异常?在C#中进行测试时,您似乎指定了带大写字母的bucket名称。 “”Itx7“” API帮助说明:
HTTP / 1.1 **400** Bad Request
......
{
**"reason":"Valid field 'bucketKey' must be of the form [-_.a-z0-9]
{3,128}"**
}
我们有一个关于bucket的博客。大多数描述仍适用于新版本:
希望这些是有用的
问候,
梁晓东
锻造Adovater开发者技术服务
欧特克