ValidationError:订阅不可用或找不到.许可证失败



我正在尝试创建一个服务,它将成为我的前端框架和shutterstock之间的中间人。我在尝试许可一个图像时遇到了一个问题,它说我的订阅无法使用或找不到。我完全按照文件上说的做了,我不知道我遗漏了什么。

let sstk = require("shutterstock-api");
sstk.setSandbox(true);
sstk.setAccessToken(process.env.SHUTTERSTOCK_TOKEN);
// Instantiate the shutterstock images api
const imagesApi = new sstk.ImagesApi();
// Instantiate the shutterstock users api
const usersApi = new sstk.UsersApi();
// Creates the body to send to shutterstock
const body = {
images: imageIds.map((imageId) => {
return {
image_id: imageId,
price: 0,
metadata: {
customer_id: "0",
},
};
}),
};
// Get subscription so we can grab the subscription id
usersApi
.getUserSubsciptionList()
.then(({ data }) => {
const subscription_id = data[0].id;
const queryParams = {
format: "jpg",
size: "huge",
subscription_id,
};
// If we successfully get the subscription id then license the images
imagesApi
.licenseImages(body, queryParams)
.then(({ data }) => {
console.log("licensedImages", data);
// Check if there was an error on any of the images
let numOfErrors = 0;
data.forEach((image) => {
if (image.error) {
numOfErrors += 1;
}
});
// If some of the images were successful
if (numOfErrors > 0 && numOfErrors < data.length) {
return errorHandler
// If all the images failed
} else if (numOfErrors > 0) {
return errorHandler
}
// If there are no errors send back the data to the frontend to manipulate it how it needs
return res.status(200).send(data);
})
.catch((err) => {
// If license error wasn't handled by Shutterstock
console.error(err);
return errorHandler
});
})
.catch((error) => {
// If subscription error wasn't handled by Shutterstock
console.error(error);
return errorHandler
});

记录的响应,状态代码为200

licensedImages [ exports {
image_id: id,
error:
'ValidationError: Subscription is unusable or cannot be found. License failed' } ]

我不知道为什么它不起作用。我已经记录了我的订阅id和图像id,它们是正确的。

格式和大小与订阅中可用的格式不匹配。

订阅是开发人员平台许可证。

我错过了什么?

这是在expressjs api 上

您的Shutterstock帐户似乎同时有"开发者平台"订阅和标准用户订阅,这会导致api出现问题。您的代码是正确的-问题是在许可流中验证您的订阅。一旦我们正确地为您的不同订阅属性,我们将通过电子邮件联系您。

最新更新