Headers 在 !ACESAPI:acesHttpOperation - Autodesk Forge
Headers in !ACESAPI:acesHttpOperation - Autodesk Forge
我在我的工作项目中使用 OnProgress 回调,但是当我尝试使用 !ACESAPI:acesHttpOperation.[=16 发送 headers 时遇到以下困难=]
- 根据https://forge.autodesk.com/blog/cannot-match-arguments-error-when-using-aceshttpoperation下面一行满足正则表达式。
[08/12/2021 22:59:57] !ACESAPI:acesHttpOperation(GetFormaletas,?pk=30204db6-fe6c-4368-99a0-972781eb66c9,Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX,,file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv)
在下方您可以看到接收每个参数的内容。
[08/12/2021 22:59:57] !!!!This is an API callback => "!ACESAPI:acesHttpOperation(GetFormaletas,?pk=30204db6-fe6c-4368-99a0-972781eb66c9,Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX,,file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv)"
[08/12/2021 22:59:57] Start processing API request acesHttpOperation.
[08/12/2021 22:59:57] Arguments => name="GetFormaletas", suffix="?pk=30204db6-fe6c-4368-99a0-972781eb66c9", headers="Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX", requestContent="", responseFile="file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv"
[08/12/2021 22:59:57] - Download variadic item from "http://e320ece2e3e5.ngrok.io/projects/get-formaletas-csv?pk=30204db6-fe6c-4368-99a0-972781eb66c9" to "T:\Aces\Jobsb53409106af4388855f42e3c4e80f1c204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv".
但是由于缺少授权,我收到了 403 header。
[08/12/2021 22:59:57] Error: API failed. Reason = Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
[08/12/2021 22:59:57] Error: Response = StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
在服务器中,当我打印请求 headers
时,也可以看到缺少 header
Received headers ==> {'Host': 'e320ece2e3e5.ngrok.io', 'X-Forwarded-For': '3.212.238.83', 'X-Forwarded-Proto': 'http', 'Accept-Encoding': 'gzip'}
Forbidden: /projects/get-formaletas-csv
HTTP GET /projects/get-formaletas-csv?pk=30204db6-fe6c-4368-99a0-972781eb66c9 403 [0.00, 127.0.0.1:54139]
在文档中我没有看到带有 header 的示例,欢迎任何指导。我也想知道如何发送多个header.
非常感谢!
如果您正在为 Inventor 使用 Design Automation API,则 VS 模板 项目实际上包含一个辅助函数为此,您可以这样称呼它:
var dict = new Dictionary<string, string>();
dict.Add("MyHeader-Item1", "MyHeader Value1");
dict.Add("MyHeader-Item2", "MyHeader Value2");
Autodesk.Forge.DesignAutomation.Inventor.Utils.OnDemand.HttpOperation("OnDemandParam", "", dict, "file://myfile");
我在工作项报告中查看了生成的内容,它在这里:
!ACESAPI:acesHttpOperation(OnDemandParam,,MyHeader-Item1=MyHeader Value1;MyHeader-Item2=MyHeader Value2,,file://myfile)
此外,检查 webhook.site 以确保它工作正常 - 它确实:
还更新了 https://forge.autodesk.com/blog/communicate-servers-inside-design-automation 以将其作为示例包含在内。
我在我的工作项目中使用 OnProgress 回调,但是当我尝试使用 !ACESAPI:acesHttpOperation.[=16 发送 headers 时遇到以下困难=]
- 根据https://forge.autodesk.com/blog/cannot-match-arguments-error-when-using-aceshttpoperation下面一行满足正则表达式。
[08/12/2021 22:59:57] !ACESAPI:acesHttpOperation(GetFormaletas,?pk=30204db6-fe6c-4368-99a0-972781eb66c9,Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX,,file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv)
在下方您可以看到接收每个参数的内容。
[08/12/2021 22:59:57] !!!!This is an API callback => "!ACESAPI:acesHttpOperation(GetFormaletas,?pk=30204db6-fe6c-4368-99a0-972781eb66c9,Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX,,file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv)"
[08/12/2021 22:59:57] Start processing API request acesHttpOperation.
[08/12/2021 22:59:57] Arguments => name="GetFormaletas", suffix="?pk=30204db6-fe6c-4368-99a0-972781eb66c9", headers="Authorization:Api-Key UI3rAhEG.rP5qlYHuwmw9664udwB9cbKs2OXMpMhX", requestContent="", responseFile="file://30204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv"
[08/12/2021 22:59:57] - Download variadic item from "http://e320ece2e3e5.ngrok.io/projects/get-formaletas-csv?pk=30204db6-fe6c-4368-99a0-972781eb66c9" to "T:\Aces\Jobsb53409106af4388855f42e3c4e80f1c204db6-fe6c-4368-99a0-972781eb66c9formaletas.csv".
但是由于缺少授权,我收到了 403 header。
[08/12/2021 22:59:57] Error: API failed. Reason = Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
[08/12/2021 22:59:57] Error: Response = StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
在服务器中,当我打印请求 headers
时,也可以看到缺少 headerReceived headers ==> {'Host': 'e320ece2e3e5.ngrok.io', 'X-Forwarded-For': '3.212.238.83', 'X-Forwarded-Proto': 'http', 'Accept-Encoding': 'gzip'}
Forbidden: /projects/get-formaletas-csv
HTTP GET /projects/get-formaletas-csv?pk=30204db6-fe6c-4368-99a0-972781eb66c9 403 [0.00, 127.0.0.1:54139]
在文档中我没有看到带有 header 的示例,欢迎任何指导。我也想知道如何发送多个header.
非常感谢!
如果您正在为 Inventor 使用 Design Automation API,则 VS 模板 项目实际上包含一个辅助函数为此,您可以这样称呼它:
var dict = new Dictionary<string, string>();
dict.Add("MyHeader-Item1", "MyHeader Value1");
dict.Add("MyHeader-Item2", "MyHeader Value2");
Autodesk.Forge.DesignAutomation.Inventor.Utils.OnDemand.HttpOperation("OnDemandParam", "", dict, "file://myfile");
我在工作项报告中查看了生成的内容,它在这里:
!ACESAPI:acesHttpOperation(OnDemandParam,,MyHeader-Item1=MyHeader Value1;MyHeader-Item2=MyHeader Value2,,file://myfile)
此外,检查 webhook.site 以确保它工作正常 - 它确实:
还更新了 https://forge.autodesk.com/blog/communicate-servers-inside-design-automation 以将其作为示例包含在内。