我的问题:
我正在编写一个python3程序,该程序对Autodesk Forge Reality Capture photo-to-3d API]使用requests.post()调用:]
https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file
但是,我似乎无法获得该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_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”:“所请求的资源不存在。”,“ moreInfo”:“ https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/”,“ errorCode”:“ org.mozilla.javascript.Undefined@0”}
以下BASH脚本应该是等效的,但它可以工作,而python请求则不行。我需要在python代码中进行哪些更改?
我的(工作中的)BASH +卷曲代码:
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脚本起作用的区别是什么?
[我的问题:我正在编写一个python3程序,该程序使用对3D Autodesk Forge Realge Capture Photo-to-3d API的request.post()调用:https://developer.api.autodesk.com/photo-to-3d / v1 / photoscene / photo -...
发布照片的正确URL应该是:https://developer.api.autodesk.com/photo-to-3d/v1/file,而不是https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/photo-to-3d/v1/file
,因此会出现404错误。
查看详细信息here