1

您好,我正在努力寻找有关如何将 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 的 Dropbox api,这是可行的。我可以定义一个名为 Dropbox-API-Arg 的 Header 并定义下载/上传路径。

任何帮助,将不胜感激。谢谢

4

3 回答 3

1

我们改进了设计自动化,因此现在使用Dropbox-API-Arg标头可用于上传和下载。以下将在您的 Dropbox 帐户中将 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"
}
于 2018-06-05T01:16:00.053 回答
1

问题是我们希望“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"
}
于 2018-06-01T15:42:20.187 回答
0

已编辑 您可以Dropbox-API-Arg按如下方式传递标题

"Name" : "Dropbox-API-Arg",
"Value" : "{\"path\":\"/test/test.pdf\", \"mode\":\"add\"}"

在有效载荷中。

或者,传递argurl 编码的字符串也可以。

使用以下有效负载通过 Forge Design Automation 与 Dropbox 一起工作。您需要传递 Arg 参数而不是 'Dropbox-API-Arg' 标头。

arg={"path":"/result.pdf"}在 URL 中编码为"arg=%7B%22path%22%3A%22%2Fresult.pdf%22%7D"

例如:

在 Dropbox 中发布 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"
}
于 2018-06-02T13:54:47.787 回答