Node.js Azure visual search API知识请求问题
我正在尝试使用facebook频道在Microsoft bot framework node v4中实现可视化搜索API,用户可以在该频道上载图像和预期的图像信息 我提到过,但面临同样的问题 我有以下代码,但API显示400无效请求: 错误消息:Node.js Azure visual search API知识请求问题,node.js,botframework,facebook-messenger-bot,azure-cognitive-services,Node.js,Botframework,Facebook Messenger Bot,Azure Cognitive Services,我正在尝试使用facebook频道在Microsoft bot framework node v4中实现可视化搜索API,用户可以在该频道上载图像和预期的图像信息 我提到过,但面临同样的问题 我有以下代码,但API显示400无效请求: 错误消息: Response: {"_type": "ErrorResponse", "instrumentation": {"_type": "ResponseInstrumentation"}, "errors": [{"code": "InvalidRequ
Response: {"_type": "ErrorResponse", "instrumentation": {"_type": "ResponseInstrumentation"}, "errors": [{"code": "InvalidRequest", "subCode": "ParameterInvalidValue", "message": "Parameter has invalid value.", "moreDetails": "Parameter has invalid value.", "parameter": "knowledgeRequest"}]}
代码段:
var imagePath = stepContext.context._activity.attachments[0].contentUrl;
var visualSearchRequest = JSON.stringify({});
var body = 'image='+imagePath ;
var postOptions = {
headers: {
'Content-Type': 'multipart/form-data; boundary=------------------------69b2c2b9c464731d' ,
"ocp-apim-subscription-key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
'Content-Disposition': 'form-data; name="image"' ,
'Content-Length': Buffer.byteLength(body) ,
'knowledgeRequest': visualSearchRequest,
'Accept': '*/*' ,
'Expect': '100-continue'
} ,
host: 'api.cognitive.microsoft.com' ,
port: null ,
path: '/bing/v7.0/images/visualsearch' ,
method: 'POST',
knowledgeRequest: visualSearchRequest,
} ;
var post_req = http.request(
postOptions,
function(res) {
//
res.setEncoding('utf8') ;
res.on('data', function (chunk) {
console.log('Response: ' + chunk) ;
}) ;
}) ;
post_req.write(body) ;
post_req.end() ;
如何解决这个问题。提前谢谢
我期待您的回复/建议。有人能提供建议吗?有人能帮我吗?