You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there ,
Firstly thanks for creating this wonderful product and We are using your mountebank as a boilerplate for our use and we are getting some issue when retrying to inject the response from UI and hitting from postman.
Below is the json response with I am trying to inject .
function processRequest(request, state, logger) {
var handlebars = require('handlebars');
logger.info('hi');
// var JSON = require("JSON3")
// var sentIn = JSON.stringify(request, null);
//logger.info('sentIn ' + sentIn);
var source = '{"Success": {{title}},"ProcessingTimeMilliseconds" : 139, "ResponseMessage": "","CreateLetter":{"OrderItemId":{{random}}}, "CancelLetter":null,"CheckLetterStatus":{{random}},"ReprintLetter":null , "ResendLetter":null}';
var ran = Math.ceil(Math.random() * 1000000);
var data = {
"title": true,
"random": ran
};
var template = handlebars.compile(source);
var textJSON = template(data);
return {
headers: {
'Content-Type': 'application/json'
},
body: textJSON,
statusCode: 200
};
After hitting from postman I am getting the below error, can you please help me with that.
{
"errors": [
{
"code": "invalid injection",
"message": "invalid response injection",
"source": "(function processRequest(request, state, logger) {\n var handlebars = require('handlebars');\n logger.info('hi');\n // var JSON = require("JSON3")\n // var sentIn = JSON.stringify(request, null);\n //logger.info('sentIn ' + sentIn);\n var source = '{"Success": {{title}},"ProcessingTimeMilliseconds" : 139, "ResponseMessage": "","CreateLetter":{"OrderItemId":{{random}}}, "CancelLetter":null,"CheckLetterStatus":{{random}},"ReprintLetter":null , "ResendLetter":null}';\n var ran = Math.ceil(Math.random() * 1000000);\n\n var data = {\n "title": true,\n "random": ran\n };\n\n var template = handlebars.compile(source);\n var textJSON = template(data);\n return {\n headers: {\n 'Content-Type': 'application/json'\n },\n body: textJSON,\n statusCode: 200\n };\n})(config, injectState, logger, deferred.resolve, imposterState);",
"data": "Parse error on line 1:\n...rderItemId":{{random}}}, "CancelLetter":\n-----------------------^\nExpecting 'CLOSE', 'OPEN_SEXPR', 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'CLOSE_UNESCAPED'",
"name": "Error",
"stack": "Error\n at Object.from (/core/src/util/inherit.js:15:17)\n at createError (/core/src/util/errors.js:10:26)\n at Object.InjectionError (/core/src/util/errors.js:21:34)\n at inject (/core/src/models/responseResolver.js:57:44)\n at processResponse (/core/src/models/responseResolver.js:297:20)\n at Object.resolve (/core/src/models/responseResolver.js:332:16)\n at match.stub.nextResponse.then.responseConfig (/core/src/models/imposter.js:130:33)\n at _fulfilled (/core/node_modules/q/q.js:854:54)\n at self.promiseDispatch.done (/core/node_modules/q/q.js:883:30)\n at Promise.promise.promiseDispatch (/core/node_modules/q/q.js:816:13)"
}
]
}
It would be a great help if you can send me the resolution for the above error.
Thanks,
Vishnu
The text was updated successfully, but these errors were encountered:
Hi there ,
Firstly thanks for creating this wonderful product and We are using your mountebank as a boilerplate for our use and we are getting some issue when retrying to inject the response from UI and hitting from postman.
Below is the json response with I am trying to inject .
function processRequest(request, state, logger) {
var handlebars = require('handlebars');
logger.info('hi');
// var JSON = require("JSON3")
// var sentIn = JSON.stringify(request, null);
//logger.info('sentIn ' + sentIn);
var source = '{"Success": {{title}},"ProcessingTimeMilliseconds" : 139, "ResponseMessage": "","CreateLetter":{"OrderItemId":{{random}}}, "CancelLetter":null,"CheckLetterStatus":{{random}},"ReprintLetter":null , "ResendLetter":null}';
var ran = Math.ceil(Math.random() * 1000000);
var data = {
"title": true,
"random": ran
};
After hitting from postman I am getting the below error, can you please help me with that.
{
"errors": [
{
"code": "invalid injection",
"message": "invalid response injection",
"source": "(function processRequest(request, state, logger) {\n var handlebars = require('handlebars');\n logger.info('hi');\n // var JSON = require("JSON3")\n // var sentIn = JSON.stringify(request, null);\n //logger.info('sentIn ' + sentIn);\n var source = '{"Success": {{title}},"ProcessingTimeMilliseconds" : 139, "ResponseMessage": "","CreateLetter":{"OrderItemId":{{random}}}, "CancelLetter":null,"CheckLetterStatus":{{random}},"ReprintLetter":null , "ResendLetter":null}';\n var ran = Math.ceil(Math.random() * 1000000);\n\n var data = {\n "title": true,\n "random": ran\n };\n\n var template = handlebars.compile(source);\n var textJSON = template(data);\n return {\n headers: {\n 'Content-Type': 'application/json'\n },\n body: textJSON,\n statusCode: 200\n };\n})(config, injectState, logger, deferred.resolve, imposterState);",
"data": "Parse error on line 1:\n...rderItemId":{{random}}}, "CancelLetter":\n-----------------------^\nExpecting 'CLOSE', 'OPEN_SEXPR', 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'CLOSE_UNESCAPED'",
"name": "Error",
"stack": "Error\n at Object.from (/core/src/util/inherit.js:15:17)\n at createError (/core/src/util/errors.js:10:26)\n at Object.InjectionError (/core/src/util/errors.js:21:34)\n at inject (/core/src/models/responseResolver.js:57:44)\n at processResponse (/core/src/models/responseResolver.js:297:20)\n at Object.resolve (/core/src/models/responseResolver.js:332:16)\n at match.stub.nextResponse.then.responseConfig (/core/src/models/imposter.js:130:33)\n at _fulfilled (/core/node_modules/q/q.js:854:54)\n at self.promiseDispatch.done (/core/node_modules/q/q.js:883:30)\n at Promise.promise.promiseDispatch (/core/node_modules/q/q.js:816:13)"
}
]
}
It would be a great help if you can send me the resolution for the above error.
Thanks,
Vishnu
The text was updated successfully, but these errors were encountered: