我正在使用React-Native构建一个向用户推荐服装的移动应用程序。我正在使用Imagga's API来获取衣服的颜色,同时不包括背景。我已经尝试通过分析documentation中给出的node.js代码来使用fetch发出POST请求:
image_file_b64 = "" + image_file_b64
//Extracting the colors from the object
let response = await fetch('https://api.imagga.com/v2/colors',{
method: 'POST',headers: {
'apiKey': '<PLACEHOLDER>','apiSecret': '<PLACEHOLDER>','Authorization': '<PLACEHOLDER>',accept: 'application/json','Content-Type': 'application/json',},body: JSON.stringify({
image_base64: image_file_b64,extract_overall_colors: 0,})
})
let responseJson = await response.json()
console.log(responseJson)
但是,我收到的唯一输出是(最后一行记录的内容):
Object {
"status": Object {
"text": "Please provide content for processing.","type": "error",}
我已经与Imagga的某人合作解决了这个问题,但是他对React Native并不熟悉。他建议将内容类型更改为“ application / x-www-form-urlencoded”或“ application / x-www-form-urlencoded; charset = UTF-8”,但均无济于事。
我非常有信心,问题出在我设置提取的方式上。如果有人熟悉Imagga API,能否请您确定代码中有什么错误或Imagga期望的内容与我提供的内容之间的格式不匹配,从而导致它不认为我已输入了它。谢谢!