Autodesk Design Automation API 使用 Dropbox 将 DWG 转换为 PDF
Autodesk Design Automation API DWG to PDF using Dropbox
您好,我正在努力寻找有关如何将 DWG 文件转换为 PDF 文件的工作示例。我正在使用 Autodesk Design Automation API 和 Dropbox。我尝试使用以下命令放置一个 WorkItem
{
"Arguments":{
"InputArguments":[
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value" : {"path":"/original.dwg"}
}
]
}
],
"OutputArguments":[
{
"Name": "Result",
"HttpVerb": "PUT",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"StorageProvider": "Generic",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value": {"path":"/test.pdf"}
}
]
}
]
}, "ActivityId": "PlotToPDF","Id": ""}
不幸的是,我收到以下错误消息
An unexpected 'StartObject' node was found for property named 'Value' when reading from the JSON reader. A 'PrimitiveValue' node was expected.
我觉得和我定义的第二个Header有关,指定要下载或上传的文件。我不清楚如何正确设置此值。
如果我在没有设计自动化 API 的情况下使用保管箱 api,这是可行的。我可以定义一个名为 Dropbox-API-Arg 的 Header 并定义为 download/upload path.
如有任何帮助,我们将不胜感激。谢谢
问题是我们期望 "Value" 是字符串,而您正在传递一个对象。这是一个工作示例:
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_imperial.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name":"Content-Type",
"Value":"application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}
已编辑
您可以通过 Dropbox-API-Arg
header 如下
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
在有效载荷中。
或者,传递 arg
url 编码的字符串也可以。
使用以下有效负载通过 Forge Design Automation 与 Dropbox 一起工作。
您需要传递 Arg 参数而不是‘Dropbox-API-Arg’header.
arg={"path":"/result.pdf"}
在 URL 中编码为 "arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D"
例如:
到 Dropbox 中的 post result.pdf。
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_metric.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload?arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D",
"StorageProvider": "Generic",
"Headers": [
{
"Name":"Authorization",
"Value":"Bearer blahblahblah"
},
{"Name":"Content-Type",
"Value":"application/octet-stream"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}
我们改进了设计自动化,现在使用 Dropbox-API-Arg
header 上传和下载均可。以下将在您的保管箱帐户中将 DWG 转换为 PDF:
{
"Arguments": {
"InputArguments": [
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.dwg\"}"
}
]
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Content-Type",
"Value" : "application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}
您好,我正在努力寻找有关如何将 DWG 文件转换为 PDF 文件的工作示例。我正在使用 Autodesk Design Automation API 和 Dropbox。我尝试使用以下命令放置一个 WorkItem
{
"Arguments":{
"InputArguments":[
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value" : {"path":"/original.dwg"}
}
]
}
],
"OutputArguments":[
{
"Name": "Result",
"HttpVerb": "PUT",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"StorageProvider": "Generic",
"Headers":[
{
"Name":"Authorization",
"Value":"Bearer xxxxxxxxxxxxxx"
},{
"Name":"Dropbox-API-Arg",
"Value": {"path":"/test.pdf"}
}
]
}
]
}, "ActivityId": "PlotToPDF","Id": ""}
不幸的是,我收到以下错误消息
An unexpected 'StartObject' node was found for property named 'Value' when reading from the JSON reader. A 'PrimitiveValue' node was expected.
我觉得和我定义的第二个Header有关,指定要下载或上传的文件。我不清楚如何正确设置此值。 如果我在没有设计自动化 API 的情况下使用保管箱 api,这是可行的。我可以定义一个名为 Dropbox-API-Arg 的 Header 并定义为 download/upload path.
如有任何帮助,我们将不胜感激。谢谢
问题是我们期望 "Value" 是字符串,而您正在传递一个对象。这是一个工作示例:
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_imperial.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name":"Content-Type",
"Value":"application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}
已编辑
您可以通过 Dropbox-API-Arg
header 如下
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
在有效载荷中。
或者,传递 arg
url 编码的字符串也可以。
使用以下有效负载通过 Forge Design Automation 与 Dropbox 一起工作。 您需要传递 Arg 参数而不是‘Dropbox-API-Arg’header.
arg={"path":"/result.pdf"}
在 URL 中编码为 "arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D"
例如:
到 Dropbox 中的 post result.pdf。
{
"Arguments": {
"InputArguments": [
{
"Resource": "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_metric.dwg",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload?arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D",
"StorageProvider": "Generic",
"Headers": [
{
"Name":"Authorization",
"Value":"Bearer blahblahblah"
},
{"Name":"Content-Type",
"Value":"application/octet-stream"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}
我们改进了设计自动化,现在使用 Dropbox-API-Arg
header 上传和下载均可。以下将在您的保管箱帐户中将 DWG 转换为 PDF:
{
"Arguments": {
"InputArguments": [
{
"Resource": "https://content.dropboxapi.com/2/files/download",
"Name": "HostDwg",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.dwg\"}"
}
]
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST",
"Resource": "https://content.dropboxapi.com/2/files/upload",
"Headers" : [
{
"Name" : "Authorization",
"Value" : "Bearer ..."
},
{
"Name" : "Content-Type",
"Value" : "application/octet-stream"
},
{
"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"
}
]
}
]
},
"ActivityId": "PlotToPDF"
}