Python 3.x 文件上传";请求的资源不存在。”;[autodesk realitycapture]
我的问题:Python 3.x 文件上传";请求的资源不存在。”;[autodesk realitycapture],python-3.x,3d,python-requests,autodesk-forge,autodesk-realitycapture,Python 3.x,3d,Python Requests,Autodesk Forge,Autodesk Realitycapture,我的问题: 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-Te
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)
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"
我正在编写一个python3程序,该程序使用requests.post()调用Autodesk Forge Reality Capture photo-to-3d API:
然而,我似乎无法让API接受我的图像文件,我将其作为可公开访问的URL传递
你能告诉我怎么做吗
我的(非工作)PYTHON+请求代码:
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)
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"
我的输出(显示错误响应):
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)
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"
文件参数={'photosceneid':'bkd3x48dsl5rpcwdfygvfghd0cmqpgexplkxlbptuu','type':'image','file[0]':''}
json_string={“developerMessage”:“请求的资源不存在”,“moreInfo”:“errorCode”:“org.mozilla.javascript”。Undefined@0“}
下面的BASH脚本应该是等效的,但它可以工作,而python请求不能。我需要在python代码中更改什么
我的(工作)BASH+curl代码:
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)
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"
那么,使Python代码失败和Bash脚本工作的区别是什么呢?发布照片的正确URL应该是:而不是
https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file
因此出现了404错误
详见