Autodesk-无法将图像上载到照片场景



我在向端点发送文件时遇到问题:https://developer.api.autodesk.com/photo-to-3d/v1/file

一旦我收到Auth令牌,我就成功地创建了一个照片场景,其中包含:https://developer.api.autodesk.com/photo-to-3d/v1/photoscene.然后,我还检查照片场景是否确实是通过调用创建的:https://developer.api.autodesk.com/photo-to-3d/v1/photoscene/${photosceneid}/属性。

如果成功,我会发送图像文件,并首先将其上传到存储服务器(因为直接发送文件不起作用(然后我运行:

let image_urls = await temporary_image_upload(files, photosceneid)
const form_data = new FormData();
form_data.append("photosceneid", photosceneid)
form_data.append("type", "image")
image_urls.forEach(url => form_data.append("file", url))
// I also tried:
// image_urls.forEach((url, index) => form_data.append(`file[${index}]`, url))
// Upload photos
const { data } = await axios.post(
"https://developer.api.autodesk.com/photo-to-3d/v1/file",
form_data,
{ headers }
)
//
//
// I also tried adding it as query params:
image_urls = image_urls.map((url, index) => `file[${index}]=${url}`).join("&")
// Upload photos
const { data } = await axios.post(
"https://developer.api.autodesk.com/photo-to-3d/v1/file",
`photosceneid=${photosceneid}&type=image&${image_urls}`,
{ headers }
)

但似乎什么都不起作用,我得到了回应:

{
Usage: '0.47925591468811',
Resource: '/file',
Error: {
code: '19',
msg: "Specified Photoscene ID doesn't exist in the database"
}
}

所以我不确定可能出了什么问题,因为我可以清楚地验证照片场景已经创建。

你能提供一些支持吗?我已经为此挣扎了几天了。

正如您所提到的,您可以清楚地确认photosceneid的存在,我怀疑您的axios请求没有达到预期,可能会添加有关标头的详细信息。这是一个示例:

Axios({
method: 'POST',
url: 'https://developer.api.autodesk.com/photo-to-3d/v1/file',
headers: {
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer ' + access_token
},
data: querystring.stringify({
photosceneid: photosceneId,
type: 'image',
'file[0]': 'https://path/to/file.JPG'
})
})

最新更新