In my remodeMethod, I set the incoming data as string like below:
{
http: {path: '/_html', verb: 'post'},
accepts: [
{arg: 'html', type: 'string', http: {source: 'body'}, description: 'HTML code.', required: true }
],
returns: {arg: 'data', type: 'object'}
}
And my request header is 'content-type': 'text/plain', my request body is plain text.
I put console.log( html ) at the first line when my function caught the variable.
It displays [object Object].
But I expect pure text. What can I do?
I tried JSON.stringify( html ) but it returns "[object Object]".
Related
I try to call putMapping from elasticsearch javascript client, but always got an error with status code 400, illegal_argument_exception.
When I call getMapping for "documents" index I got:
{
"documents":{
"mappings": {
"properties":{
"category":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"createdAt":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"id":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"info":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"text":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"title":{"type":"text","fields":{"keyword":
{"type":"keyword","ignore_above":256}}},
"visibility":{"type":"boolean"}
}
}
}
}
I tried to call putMapping with same properties and add a new parameter 'index': 'not_analyzed' to category field:
esClient.indices.putMapping({
index: 'documents',
type: 'document',
body: {
document: {
properties: {
title: { type: 'text' },
info: { type: 'text' },
text: { type: 'text' },
category: { type: 'text', index:
'not_analyzed'
},
visibility: { type: 'boolean' },
createdAt: { type: 'text' },
},
},
},
}, (err, resp) => {
if (err) {
console.error(err);
}
else {
console.log('Successfully Created Index', resp);
}
});
I got this error:
ResponseError: illegal_argument_exception
at IncomingMessage.<anonymous> (/Users/user/reference_sys_cfu-back/node_modules/#elastic/elasticsearch/lib/Transport.js:287:25)
at IncomingMessage.emit (events.js:208:15)
at IncomingMessage.EventEmitter.emit (domain.js:476:20)
at endReadableNT (_stream_readable.js:1168:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
name: 'ResponseError',
meta: {
body: { error: [Object], status: 400 },
statusCode: 400,
headers: {
'content-type': 'application/json; charset=UTF-8',
'content-length': '345'
},
warnings: null,
meta: {
context: null,
request: [Object],
name: 'elasticsearch-js',
connection: [Object],
attempts: 0,
aborted: false
}
}
}
index: 'not_analyzed' - I do this for use "term" method for exact finding strings, but it (index: 'not_analyzed') deprecated in 2.x version of elasticsearch. Now I just use field.keyword: 'query string', to finding exact strings.
I am using Adonisjs v5 and Angular 7. When I tried to upload file with formData from frontend then it throws the error
error: invalid JSON, only supports object and array
I believe it is bodyParse error, but I have not been able to resolve it.
Error: invalid JSON, only supports object and array
at parse (/Users/api/node_modules/co-body/lib/json.js:55:13)
at AsyncFunction.module.exports [as json] (/Users/api/node_modules/co-body/lib/json.js:41:20)
at process.internalTickCallback (internal/process/next_tick.js:77:7)"
Here is my Angular code:-
const formData: FormData = new FormData();
formData.append('name', this.name);
formData.append('image', this.image, this.image.name);
this.api.upload("/profile", formData,)
.subscribe((response: Response) => {
Here is my bodyParser config :-
json: {
limit: '1mb',
strict: true,
types: [
'application/json',
'application/json-patch+json',
'application/vnd.api+json',
'application/csp-report'
]
},
raw: {
types: [
'text/*'
]
},
form: {
types: [
'application/x-www-form-urlencoded'
]
},
files: {
types: [
'multipart/form-data'
],
maxSize: '20mb',
autoProcess: true,
processManually: []
I have created some messages in chatbase using session_id to divide sessions. However, these are not shown as separate flows. They appear as concatenated flows.
Example messages:
[ { api_key: 'xxxx',
type: 'user',
user_id: 'Lee',
time_stamp: 1559340845342,
platform: 'Chat_Test2',
session_id: '200',
message: '_',
intent: 'choice',
not_handled: 'false',
version: '1.1' },
{ api_key: 'xxxx',
type: 'agent',
user_id: 'Lee',
time_stamp: 1559340845341,
platform: 'Chat_Test2',
session_id: '200',
message: 'what_would_you_like',
version: '1.1' } ]
[ { api_key: 'xxxx',
type: 'user',
user_id: 'Lee',
time_stamp: 1559340848284,
platform: 'Chat_Test2',
session_id: '201',
message: 'hello',
intent: 'Welcome',
not_handled: 'false',
version: '1.1' },
{ api_key: 'xxxx',
type: 'agent',
user_id: 'Lee',
time_stamp: 1559340848283,
platform: 'Chat_Test2',
session_id: '201',
message: 'hello_how_can_I_help',
version: '1.1' } ]
Thank you for your question and providing the example JSON payload. I see that are numbering your session id's sequentially. You will need to label each utterance with a given session with the same session id. The utterances within each session will then be sorted by timestamp.
If you continue to experience issues, please contact chatbase-support#google.com with your bot's api key and I will be happy to look into your issue directly.
I am using nuxt.js encountered this error TypeError [ERR_INVALID_ARG_TYPE]: The 'request' argument must be string. Received type undefined while running the project what does this error mean?
I tried npm install nothing works.
I think it's node js problem.
Following is my config file
const pkg = require('./package')
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'stylesheet', type: 'text/css', href: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'},
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Open+Sans|Source+Sans+Pro'}
]
}
Looks like the package-lock.json was the issue when I got that error. I've removed it and reinstalled node modules. It works fine ever after. You might want to check if that would work in your situation.
I'm trying to create a remote method that accepts XML, i define my remote method like this,
WechatModel.remoteMethod('notify', {
description: 'notify',
accepts: [
{
arg: 'response',
type: 'string',
required: true,
http: {
source: 'body',
},
},
],
http: {
verb: 'post',
path: '/notify',
},
});
then i changed my server/config.js like this:
"rest": {
"normalizeHttpPath": false,
"xml": true
},
but,i still got a string with the content "[object Object]"