mcgregor94086
mcgregor94086

Reputation: 1529

File upload "The requested resource does not exist." [autodesk-realitycapture]

My problem:

I am writing a python3 program which uses a requests.post() call to the Autodesk Forge Reality Capture photo-to-3d API:

https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file

However, I can't seem to get the API to accept my image file(s), which I pass as a publicly accessible URLs.

Can you show me how it should be done?

My (Non-working) PYTHON + requests code:

forge_url = "https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file"
headers = {'Content-type': 'application/x-www-form-urlencoded'}
image_url_list = { 'http://siptea.net/wp-content/uploads/2017/02/Persimmon-Ceramic-Teapot-Sip-Tea-4786.jpg' }

for file_url in image_url_list:
    file_parameters = {'photosceneid': photoscene_id, 'type': 'image', 'file[0]': file_url}
    print("file_parameters = ", file_parameters)
    response = requests.post(forge_url, auth=BearerAuth(access_token), headers=headers, data=file_parameters)
    json_object = response.json()
    json_string = json.dumps(json_object)
    print("json_string = ", json_string)

My output (showing error response):

file_parameters = {'photosceneid': 'bkd3x48dSl5RpcwdfWYgVfGhD0cMQPgexpLkXLbPtUU', 'type': 'image', 'file[0]': 'http://siptea.net/wp-content/uploads/2017/02/Persimmon-Ceramic-Teapot-Sip-Tea-4786.jpg'}

json_string = {"developerMessage": "The requested resource does not exist.", "moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/", "errorCode": "org.mozilla.javascript.Undefined@0"}

The following BASH script should be equivalent, but it works and the python request does not. What do I need to change in my python code?

My (working) BASH + curl code:

 file_url="http://siptea.net/wp-content/uploads/2017/02/Persimmon-Ceramic-Teapot-Sip-Tea-4786.jpg"
 json=`curl -s https://developer.api.autodesk.com/photo-to-3d/v1/file \
     -H "Authorization: Bearer $access_token" \
     -d "photosceneid=$photoscene_id" \
     -d 'type=image' \
     -d "file[0]=$file_url"

So what is the difference that makes the Python code fail and the Bash script work?

Upvotes: 0

Views: 1394

Answers (1)

Bryan Huang
Bryan Huang

Reputation: 5342

The correct URL to post photos should be: https://developer.api.autodesk.com/photo-to-3d/v1/file and not https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file so hence the 404 error.

See details here

Upvotes: 0

Related Questions