Open paule96 opened 2 months ago
Thank you @paule96 , that is probably because the body is being treated as a JSON.
When the body itself is not a JSON object we should return the raw content, instead of considering it a JSON Token.
@paule96 , as a workaround you can always use a raw response file like this:
1) Create a file named foo.txt 2) Setup your mock
{
"request": {
"method": "GET",
"route": "/raw-string-example"
},
"response": {
"status": "OK",
"file": "Mocks/foo.txt"
}
}
Then
$ curl -iX GET http://localhost:5000/raw-string-example
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sun, 15 Sep 2024 19:04:53 GMT
Server: Kestrel
Transfer-Encoding: chunked
This is a raw string
Hi @natenho,
yes, I know about that option. But it sounds a bit weird to me for short responses to create an extra file. It would be easier to define it directly in the JSON itself
@paule96 Absolutely! Just wanted to give you a workaround so you're not blocked.
Prerequisites
Description
If you provide a mock JSON that should return in the body a string, the actual HTTP response includes always the quotes of the string. That is an issue because normally in the dotnet world if an API just returns a string, it is not enclosed into quoates.
Steps to reproduce
Sample mock file:
If you run the mockaco container with this file you will get the following response:
Expected behavior
The expexted behavior should be more like:
Screenshots
No response
Additional context
If a user wants explicitly return a string with quotes, he should use normal JSON escaping: