Autodesk forge 调用workitem api时,Autodesk.DesignAutomation在位置0处返回JSON中的意外标记

Autodesk forge 调用workitem api时,Autodesk.DesignAutomation在位置0处返回JSON中的意外标记,autodesk-forge,autodesk-designautomation,Autodesk Forge,Autodesk Designautomation,我正面临着一个新问题 handleSendToForge(e) { e.preventDefault(); let formData = new FormData(); formData.append('data', JSON.stringify({ Width: this.state.Width, Length: this.state.Length, Depth: thi

我正面临着一个新问题

handleSendToForge(e) {
        e.preventDefault();


        let formData = new FormData();
        formData.append('data', JSON.stringify({
            Width: this.state.Width,
            Length: this.state.Length,
            Depth: this.state.Depth,
            Thickness: this.state.Thickness,
            BottomThickness: this.state.BottomThickness,
            rebarSpacing: this.state.rebarSpacing,
            outputrvt: this.state.outputrvt,
            bucketId: this.state.bucketId,
            activityId: 'RVTDrainageWebappActivity',
            objectId: 'template.rvt'
        }));

        this.setState({
            form: formData
        })


        fetch('designautomation', {
            method: 'POST',
            body: formData,
            //headers: {
            //    //'Content-Type': 'application/json'
            //    'Content-Type': 'application/x-www-form-urlencoded',
            //},
        })
            .then(response => response.json())
            .then(data => { console.log(data) })
            .catch(error => console.log(error));
    }
控制器的代码是相当标准的,并且从forge的一个示例中稍微修改了一下

[HttpPost]
        [Route("designautomation")]
        public async Task<IActionResult> Test([FromForm] StartWorkitemInput input)
        {

            JObject workItemData = JObject.Parse(input.data);
            double Width = workItemData["Width"].Value<double>();
            double Length = workItemData["Length"].Value<double>();
            double Depth = workItemData["Depth"].Value<double>();
            double Thickness = workItemData["Thickness"].Value<double>();
            double BottomThickness = workItemData["BottomThickness"].Value<double>();
            double rebarSpacing = workItemData["rebarSpacing"].Value<double>();
            string outputrvt = workItemData["outputrvt"].Value<string>();
            string activityId = workItemData["activityId"].Value<string>();
            string bucketId = workItemData["bucketId"].Value<string>();
            string objectId = workItemData["objectId"].Value<string>();

            // basic input validation
            string activityName = string.Format("{0}.{1}", NickName, activityId);
            string bucketKey = bucketId;
            string inputFileNameOSS = objectId;

            // OAuth token
            dynamic oauth = await OAuthController.GetInternalAsync();

            // prepare workitem arguments
            // 1. input file
            dynamic inputJson = new JObject();
            inputJson.Width = Width;
            inputJson.Length = Length;
            inputJson.Depth = Depth;
            inputJson.Thickness = Thickness;
            inputJson.BottomThickness = BottomThickness;
            inputJson.rebarSpacing = rebarSpacing;
            inputJson.outputrvt = outputrvt;

            XrefTreeArgument inputFileArgument = new XrefTreeArgument()
            {
                Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/aecom-bucket-demo-library/objects/{0}", objectId),
                Headers = new Dictionary<string, string>()
                {
                    { "Authorization", "Bearer " + oauth.access_token }
                }
            };

            // 2. input json
            XrefTreeArgument inputJsonArgument = new XrefTreeArgument()
            {
                Headers = new Dictionary<string, string>()
                {
                    {"Authorization", "Bearer " + oauth.access_token }
                },
                Url = "data:application/json, " + ((JObject)inputJson).ToString(Formatting.None).Replace("\"", "'")
            };

            // 3. output file
            string outputFileNameOSS = outputrvt;
            XrefTreeArgument outputFileArgument = new XrefTreeArgument()
            {
                Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, outputFileNameOSS),
                Verb = Verb.Put,
                Headers = new Dictionary<string, string>()
                {
                    {"Authorization", "Bearer " + oauth.access_token }
                }
            };

            // prepare & submit workitem
            // the callback contains the connectionId (used to identify the client) and the outputFileName of this workitem
            //string callbackUrl = string.Format("{0}/api/forge/callback/designautomation?id={1}&bucketKey={2}&outputFileName={3}", OAuthController.FORGE_WEBHOOK_URL, browerConnectionId, bucketKey, outputFileNameOSS);
            WorkItem workItemSpec = new WorkItem()
            {
                ActivityId = activityName,
                Arguments = new Dictionary<string, IArgument>()
                {
                    { "rvtFile",  inputFileArgument },
                    { "jsonFile",  inputJsonArgument },
                    { "result",  outputFileArgument }
                    ///{ "onComplete", new XrefTreeArgument { Verb = Verb.Post, Url = callbackUrl } }
                }
            };

            DesignAutomationClient client = new DesignAutomationClient();
            client.Service.Client.BaseAddress = new Uri(@"http://localhost:3000");


            WorkItemStatus workItemStatus = await client.CreateWorkItemAsync(workItemSpec);

            return Ok();
        }
[HttpPost]
[路线(“设计自动化”)]
公共异步任务测试([FromForm]StartWorkitemInput)
{
JObject workItemData=JObject.Parse(input.data);
双宽度=工作项数据[“宽度”]。值();
double Length=workItemData[“Length”].Value();
双深度=工作项数据[“深度”]。值();
双厚度=工作项数据[“厚度”]。值();
double BottomThickness=工作项数据[“BottomThickness”]。值();
double rebarspace=workItemData[“rebarspace”].Value();
字符串outpurtvt=workItemData[“outpurtvt”].Value();
字符串activityId=workItemData[“activityId”].Value();
字符串bucketId=workItemData[“bucketId”].Value();
字符串objectId=workItemData[“objectId”].Value();
//基本输入验证
string activityName=string.Format(“{0}.{1}”,昵称,activityId);
字符串bucketKey=bucketId;
字符串inputFileNameOSS=objectId;
//OAuth令牌
dynamic oauth=等待OAuthController.GetInternalAsync();
//准备工作项参数
//1.输入文件
动态inputJson=new JObject();
inputJson.Width=宽度;
inputJson.Length=长度;
inputJson.Depth=深度;
inputJson.Thickness=厚度;
inputJson.BottomThickness=底部厚度;
inputJson.rebarspace=rebarspace;
inputJson.outputrvt=outputrvt;
XrefTreeArgument inputFileArgument=新的XrefTreeArgument()
{
Url=string.Format(“https://developer.api.autodesk.com/oss/v2/buckets/aecom-bucket-demo-library/objects/{0},objectId),
Headers=newdictionary()
{
{“授权”、“承载”+oauth.access_token}
}
};
//2.输入json
XrefTreeArgument inputJsonArgument=新的XrefTreeArgument()
{
Headers=newdictionary()
{
{“授权”、“承载”+oauth.access_token}
},
Url=“data:application/json,”+((JObject)inputJson).ToString(Formatting.None).Replace(“\”,“”)
};
//3.输出文件
字符串outputFileNameOSS=outputrvt;
XrefTreeArgument outputFileArgument=新的XrefTreeArgument()
{
Url=string.Format(“https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}”,bucketKey,outputFileNameOSS),
动词,
Headers=newdictionary()
{
{“授权”、“承载”+oauth.access_token}
}
};
//准备并提交工作项目
//回调包含此工作项的connectionId(用于标识客户端)和outputFileName
//string callbackUrl=string.Format(“{0}/api/forge/callback/designautomation?id={1}&bucketKey={2}&outputFileName={3}”,OAuthController.forge_WEBHOOK_URL,browerConnectionId,bucketKey,outputFileNameOSS);
WorkItem workItemSpec=新的WorkItem()
{
ActivityId=activityName,
参数=新字典()
{
{“rvtFile”,inputFileArgument},
{“jsonFile”,inputjsonaargument},
{“结果”,outputFileArgument}
///{“onComplete”,新的xretreeargument{Verb=Verb.Post,Url=callbackUrl}
}
};
DesignAutomationClient=新的DesignAutomationClient();
client.Service.client.BaseAddress=新Uri(@“http://localhost:3000");
WorkItemStatus WorkItemStatus=等待客户端.CreateWorkItemAsync(workItemSpec);
返回Ok();
}
你知道为什么会给我这个错误吗?我已经使用postman测试了api,它工作得很好,但是当我尝试从按钮调用它时,我总是收到这个错误。开始调试时,url似乎写得正确。也许这是我缺少的一件非常简单的事情。 干杯!

好的。。。 我没有在启动时添加服务,也没有在appsettings.json中添加伪造连接信息(clientid,clientsecret)

现在我需要测试AWS部署,我想我已经完成了