Comments (7)
@bbyars so, I have some JSON files that to be included in the body
response, do you have a temporary solution for this?
from mountebank.
Hi Chris,
Can you provide some context? Are you aiming to return the content of the
file as the JSON response? If so, then can you use the client code calling
mountebank to read the file and pass the content as the body field of the
response?
-Brandon
On Sun, Nov 9, 2014 at 7:13 PM, Chris Chen [email protected] wrote:
@bbyars https://github.com/bbyars so, I have some JSON files that to be
included in the body response, do you have a temporary solution for this?—
Reply to this email directly or view it on GitHub
#27 (comment).
from mountebank.
@bbyars you're right. I'm currently using shell script to read JSON content from a file, and trying to "inject" the JSON data in the body
response field, when I'm calling POST http://localhost:2525.
But I'm not proficient to this shell script thing, so I thought it would be nice for mountebank to allow "attach" a JSON file as part of the body
response
from mountebank.
Got it. In that case, it sounds like setting an environment variable to
cat contents.json
and interpolating that variable in the body response
field will work.
On Sun, Nov 9, 2014 at 8:33 PM, Chris Chen [email protected] wrote:
@bbyars https://github.com/bbyars you're right. I'm currently using
shell script to read JSON content from a file, and trying to "inject" the
JSON data in the body response field, when I'm calling POST
http://localhost:2525.—
Reply to this email directly or view it on GitHub
#27 (comment).
from mountebank.
@bbyars thanks, finally got it work
schema_compact.json
{\"customer\":{\"questions\":[{\"label\":\"First Name\",\"required\":false}]}}
data_compact.json
{}
script.sh
echo $'delete all existing stubs\n'
curl --request 'DELETE' http://localhost:2525/imposters
echo $'\n'
echo $'import stubs\n'
SCHEMA_JSON=$(cat schema_compact.json)
DATA_JSON=$(cat data_compact.json)
CURL_DATA='{"port":6677,"protocol":"http","stubs":[{"responses":[{"is":{"statusCode":406}}],"predicates":[{"not":{"equals":{"headers":{"Accept":"application/json"}}}}]},{"responses":[{"is":{"statusCode":200,"headers":{"content-type":"application/json"},"body":'"$SCHEMA_JSON"'}}],"predicates":[{"equals":{"method":"GET","path":"/schema"}}]},{"responses":[{"is":{"statusCode":200,"headers":{"content-type":"application/json"},"body":"'"$DATA_JSON"'"}}],"predicates":[{"equals":{"method":"GET","path":"/data"}}]}]}'
curl -i \
--request 'POST' \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
--data "$CURL_DATA" \
http://localhost:2525/imposters
echo $'\n'
from mountebank.
perfect - glad you got it working!
On Sun, Nov 9, 2014 at 9:23 PM, Chris Chen [email protected] wrote:
sorry, figured out, I should use:
curl -i
--request 'POST'
-H "Accept: application/json"
-H "Content-Type:application/json"
--data "$CURL_DATA" \http://localhost:2525/impostersecho $'\n'—
Reply to this email directly or view it on GitHub
#27 (comment).
from mountebank.
would prefer this to be in client libraries to keep it portable
from mountebank.
Related Issues (20)
- mountebank issue when the mock is >35000 line HOT 6
- Getting error trying to create a mock with mountebank HOT 1
- Unable to use different type other than string(s) when injecting responses via CSV lookup
- Add binary body representation for http(s) requests for /imposters/{key} endpoint
- Stable release with ARM support
- Master commits break projects using the latest version HOT 3
- Creating & deleting imposters in a load balanced setup HOT 1
- EACCES: permission denied, open 'mb.pid' with version `2.8.1` HOT 2
- Expect field in the header HOT 1
- Mountebank doesn't show imposters metrics
- QUESTION: How to copy (behavior) integer value from path to body field? HOT 1
- ee key too small HOT 6
- How to close tcp connection by Imposter HOT 1
- [Feature Request] Allow mountebank to send back statusMesage
- Mongodb as log transport
- bug in src/util/helpers.js merge function for case with an Array field
- Mountebank beautifies JSON responses from proxies before replying to the caller.
- Copied request object coming back as `[object Object]`
- Mocha test hangs after all tests pass when `imposters` endpoint is called. HOT 1
- How to configure mountebank to handle subdomains?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mountebank.