使用本地文件和 URL 将图像文件添加到 Autodesk 的 Forge API 中的照片场景都失败了

Both using local files and URLs to add image files to a photoscene in Autodesk's Forge API are failing

我无法在 Autodesk 的 Forge API.

将图像文件添加到照片场景

我尝试过使用两种方法,两种都失败了,尽管每种方法都有不同 错误信息:

使用 URL:

指定文件
json=`curl -v -s $FORGE_URL/photo-to-3d/v1/file \
        -H "Authorization: Bearer $forge_access_token" \
        -d "photosceneid=$photosceneid" \
        -d 'type=image' \
        -d "file[1]=http://cloud1.tri-di.com/scans/VG1.3/20200617191821/img01-cam00-USB+2.0+Camera+26.jpg" 

以上代码产生以下错误:

{
  "msg": "An error occurred while trying to copy the file",
  "code": "34"
}

指定文件使用本地文件名:

当我 cd 到包含图像文件的本地目录时,我可以这样指定文件[1]:

    json=`curl -v -s $FORGE_URL/photo-to-3d/v1/file \
    -H "Authorization: Bearer $forge_access_token" \
    -d "photosceneid=$photosceneid" \
    -d 'type=image' \
    -d "file[1]=img01-cam00-USB+2.0+Camera+26.jpg" 
`

然后我收到以下错误消息:

{
  "msg": "Specified image protocol is invalid",
  "code": "18"
}

调用 curl -v 提供以下调试信息。

  Trying 34.197.193.140...
* Connected to developer.api.autodesk.com (34.197.193.140) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 598 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: developer.api.autodesk.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: businessCategory=Private Organization,jurisdictionOfIncorporationCountryName=US,jurisdictionOfIncorporationStateOrProvinceName=Delaware,serialNumber=2401504,C=US,ST=California,L=San Rafael,O=Autodesk\, Inc.,OU=MCP-ASRD-CP,CN=developer.api.autodesk.com
*    start date: Mon, 24 Feb 2020 00:00:00 GMT
*    expire date: Mon, 22 Mar 2021 12:00:00 GMT
*    issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 Extended Validation Server CA
*    compression: NULL
* ALPN, server did not agree to a protocol
> POST /photo-to-3d/v1/file HTTP/1.1
> Host: developer.api.autodesk.com
> User-Agent: curl/7.47.0
> Accept: */*
> Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJzY29wZSI6WyJkYXRhOnJlYWQiLCJkYXRhOndyaXRlIl0sImNsaWVudF9pZCI6IkhBcUR0S083VmJ1UmdIMG5MME1GSjBCMDJFbEJFSzNsIiwiYXVkIjoiaHR0cHM6Ly9hdXRvZGVzay5jb20vYXVkL2p3dGV4cDYwIiwianRpIjoid2lwVWw2dGNCdndPdnYzT29jVWV0anFQNFRMOXBiZVdGZm80NGtGUWhDYVpudGJ5OXZCcFdNTWpjYU1IeDRhTSIsImV4cCI6MTU5MjQ1MDM5MH0.j2_DaSyZGhs87MqtugollT1D-1Tv4-zkBDaQwjKT8yg
> Content-Length: 142
> Content-Type: application/x-www-form-urlencoded
> 
} [142 bytes data]
* upload completely sent off: 142 out of 142 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Thu, 18 Jun 2020 02:59:26 GMT
< Server: Apache/2.4.6 (CentOS)
< X-Powered-By: PHP/7.0.33
< Content-Length: 126
< Connection: keep-alive
< 

有没有人遇到过类似的问题?你是怎么解决的?

不是将所有信息作为数据发送(-d 标志),而是将其作为表单内容发送(-F 标志):

curl --location --request POST 'https://developer.api.autodesk.com/photo-to- 3d/v1/file' \
-H "Authorization: Bearer $TOKEN" \
-F "photosceneid=$PHOTOSCENE" \
-F "type=image" \
-F "file[0]=http://cloud1.tri-di.com/scans/VG1.3/20200617191821/img01-cam00-USB+2.0+Camera+26.jpg"

我会向工程团队报告更改文档以反映此方法。