当我试图在cloudsearch上传一个文档时,我无法处理这个错误

我正在尝试使用Aws lambda函数对cloudsearch进行上传testing。 该函数应该上传一个dynamodb表格作为JSON文件到cloudsearch当dynamodb更新被触发,但我得到一个错误,我想弄清楚是什么意思,如何摆脱。

目前,我正在configurationtesting事件

这里是lambda函数:

var aws = require('aws-sdk'); exports.handler = function(event,context){ var cloudsearchdomain = new aws.CloudSearchDomain({endpoint: 'doc-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cloudsearch.amazonaws.com'}); var documents = {id : event.Records[0].dynamodb.Keys.Id.N}; documents.type = "add"; documents.fields = { "message" : "Hello", "id" : "100", "name" : "name" } var params = {contentType: 'application/json', documents : JSON.stringify(documents) }; console.log('uploading documents to cloudsearch domain', params); cloudsearchdomain.uploadDocuments(params, function(err, data) { if(err) { console.log('Error uploading documents to cloudsearch', err, err.stack); context.done(null,err); } else { context.done(null,"Successfully processed"); } }); } 

我得到的错误消息:

 { "message": "{ [\"The first non-whitespace character in the file must be '['\"] }", "code": "DocumentServiceException", "time": "2016-04-26T10:56:18.858Z", "requestId": "814bp1d66-0basd-11e6-b7fc-b9b1ad0761693", "statusCode": 400, "retryable": false, "retryDelay": 17.98068769276142 } 

任何帮助将不胜感激。 谢谢

出现此错误是因为CloudSearch希望消息是一个对象数组,而只是发送一个对象。