autodesk-forgeautodesk-realitycapture

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


I am failing to add image files to a photoscene in Autodesk's Forge API.

I have attempted this using two methods and both are failing, though each with a different error message:

Specifying the file using a 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" 

The above code generates the following error:

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

Specifying the file using a local filename:

When I cd to the local directory containing the image files, I can specify the files[1] like this:

    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" 
`

then I am getting the following error message instead:

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

Calling curl -v provides the following debugging information.

  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
< 

Has anyone else had a similar problem? How did you resolve it?


Solution

  • Instead of sending all info as data (-d flag), send it as a form content (-F flag):

    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"
    

    I will report to engineering team to have documentation changed to reflect this approach.