We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the issue Mustache template unable to access body.
What you are trying to do Description of what you are trying to do so we can understand the context of the problem
MockServer version 5.15.0
To Reproduce Steps to reproduce the issue:
mockServerClient("localhost", 1081) .mockAnyResponse({ "httpRequest": { "method": "POST", "path": "/mock-endpoint", "headers": { "Content-Type": ["application/json"] }, "body": { "type": "JSON", }
}, "httpResponseTemplate": { "template": JSON.stringify({ "statusCode": 200, "headers": { "Content-Type": ["application/json"] }, "body": { "id": "{{ uuid }}", "time": "{{ now_iso_8601 }}", 'message': "{{{jsonPath request.body '$.message'}}}", 'to': '{{{ request.body.to }}}', 'from': '1111111111111' }, 'delay': { 'timeUnit': 'MILLISECONDS', } }), "templateType": "MUSTACHE", },
Expected behaviour To return field
MockServer Log 2024-10-02 17:03:32 5.15.0 INFO 1081 request:
{ "method" : "POST", "path" : "/mock-endpoint", "headers" : { "user-agent" : [ "PostmanRuntime/7.42.0" ], "postman-token" : [ "d858c7d9-d7b9-4ff0-bea9-255399791bcf" ], "host" : [ "172.22.118.120:1081" ], "content-type" : [ "application/json" ], "content-length" : [ "152" ], "connection" : [ "keep-alive" ], "accept-encoding" : [ "gzip, deflate, br" ], "accept" : [ "/" ] }, "keepAlive" : true, "secure" : false, "protocol" : "HTTP_1_1", "localAddress" : "127.0.0.1:1081", "remoteAddress" : "127.0.0.1:37752", "body" : { "message" : "Your message content", "to" : [ "+1234567890" ], "from" : "+13473450776", "media" : [ ], "priority" : "default", "tags" : { } } }
matched expectation:
{ "httpRequest" : { "method" : "POST", "path" : "/mock-endpoint", "headers" : { "Content-Type" : [ "application/json" ] } }, "httpResponseTemplate" : { "template" : "{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}", "templateType" : "MUSTACHE" }, "id" : "788c5024-0027-426a-a36e-859a4691f073", "priority" : 0, "timeToLive" : { "unlimited" : true }, "times" : { "unlimited" : true } }
2024-10-02 17:03:32 5.15.0 INFO 1081 generated output:
{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"07348bcf-c348-4e22-adb2-f138cc348257","time":"2024-10-02T16:03:32.868205485Z","message":"","to":"","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}
from template:
{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}
for request:
2024-10-02 17:03:32 5.15.0 INFO 1081 returning response:
{ "statusCode" : 200, "headers" : { "Content-Type" : [ "application/json" ] }, "body" : { "id" : "07348bcf-c348-4e22-adb2-f138cc348257", "time" : "2024-10-02T16:03:32.868205485Z", "message" : "", "to" : "", "from" : "1111111111111" }, "delay" : { "timeUnit" : "MILLISECONDS", "value" : 0 } }
for action:
{ "template" : "{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}", "templateType" : "MUSTACHE" }
from expectation:
788c5024-0027-426a-a36e-859a4691f073
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the issue
Mustache template unable to access body.
What you are trying to do
Description of what you are trying to do so we can understand the context of the problem
MockServer version
5.15.0
To Reproduce
Steps to reproduce the issue:
mockServerClient("localhost", 1081)
.mockAnyResponse({
"httpRequest": {
"method": "POST",
"path": "/mock-endpoint",
"headers": {
"Content-Type": ["application/json"]
},
"body": {
"type": "JSON",
}
Expected behaviour
To return field
MockServer Log
2024-10-02 17:03:32 5.15.0 INFO 1081 request:
{
"method" : "POST",
"path" : "/mock-endpoint",
"headers" : {
"user-agent" : [ "PostmanRuntime/7.42.0" ],
"postman-token" : [ "d858c7d9-d7b9-4ff0-bea9-255399791bcf" ],
"host" : [ "172.22.118.120:1081" ],
"content-type" : [ "application/json" ],
"content-length" : [ "152" ],
"connection" : [ "keep-alive" ],
"accept-encoding" : [ "gzip, deflate, br" ],
"accept" : [ "/" ]
},
"keepAlive" : true,
"secure" : false,
"protocol" : "HTTP_1_1",
"localAddress" : "127.0.0.1:1081",
"remoteAddress" : "127.0.0.1:37752",
"body" : {
"message" : "Your message content",
"to" : [ "+1234567890" ],
"from" : "+13473450776",
"media" : [ ],
"priority" : "default",
"tags" : { }
}
}
matched expectation:
{
"httpRequest" : {
"method" : "POST",
"path" : "/mock-endpoint",
"headers" : {
"Content-Type" : [ "application/json" ]
}
},
"httpResponseTemplate" : {
"template" : "{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}",
"templateType" : "MUSTACHE"
},
"id" : "788c5024-0027-426a-a36e-859a4691f073",
"priority" : 0,
"timeToLive" : {
"unlimited" : true
},
"times" : {
"unlimited" : true
}
}
2024-10-02 17:03:32 5.15.0 INFO 1081 generated output:
{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"07348bcf-c348-4e22-adb2-f138cc348257","time":"2024-10-02T16:03:32.868205485Z","message":"","to":"","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}
from template:
{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}
for request:
{
"method" : "POST",
"path" : "/mock-endpoint",
"headers" : {
"user-agent" : [ "PostmanRuntime/7.42.0" ],
"postman-token" : [ "d858c7d9-d7b9-4ff0-bea9-255399791bcf" ],
"host" : [ "172.22.118.120:1081" ],
"content-type" : [ "application/json" ],
"content-length" : [ "152" ],
"connection" : [ "keep-alive" ],
"accept-encoding" : [ "gzip, deflate, br" ],
"accept" : [ "/" ]
},
"keepAlive" : true,
"secure" : false,
"protocol" : "HTTP_1_1",
"localAddress" : "127.0.0.1:1081",
"remoteAddress" : "127.0.0.1:37752",
"body" : {
"message" : "Your message content",
"to" : [ "+1234567890" ],
"from" : "+13473450776",
"media" : [ ],
"priority" : "default",
"tags" : { }
}
}
2024-10-02 17:03:32 5.15.0 INFO 1081 returning response:
{
"statusCode" : 200,
"headers" : {
"Content-Type" : [ "application/json" ]
},
"body" : {
"id" : "07348bcf-c348-4e22-adb2-f138cc348257",
"time" : "2024-10-02T16:03:32.868205485Z",
"message" : "",
"to" : "",
"from" : "1111111111111"
},
"delay" : {
"timeUnit" : "MILLISECONDS",
"value" : 0
}
}
for request:
{
"method" : "POST",
"path" : "/mock-endpoint",
"headers" : {
"user-agent" : [ "PostmanRuntime/7.42.0" ],
"postman-token" : [ "d858c7d9-d7b9-4ff0-bea9-255399791bcf" ],
"host" : [ "172.22.118.120:1081" ],
"content-type" : [ "application/json" ],
"content-length" : [ "152" ],
"connection" : [ "keep-alive" ],
"accept-encoding" : [ "gzip, deflate, br" ],
"accept" : [ "/" ]
},
"keepAlive" : true,
"secure" : false,
"protocol" : "HTTP_1_1",
"localAddress" : "127.0.0.1:1081",
"remoteAddress" : "127.0.0.1:37752",
"body" : {
"message" : "Your message content",
"to" : [ "+1234567890" ],
"from" : "+13473450776",
"media" : [ ],
"priority" : "default",
"tags" : { }
}
}
for action:
{
"template" : "{"statusCode":200,"headers":{"Content-Type":["application/json"]},"body":{"id":"{{ uuid }}","time":"{{ now_iso_8601 }}","message":"{{{jsonPath request.body '$.message'}}}","to":"{{{ request.body.to }}}","from":"1111111111111"},"delay":{"timeUnit":"MILLISECONDS"}}",
"templateType" : "MUSTACHE"
}
from expectation:
788c5024-0027-426a-a36e-859a4691f073
The text was updated successfully, but these errors were encountered: