I know if i have node installed i can spin up JSON mock server in no time and then i can create endpoints which support GET,PUT,POST etc. Also i realise that data can be stored (like insertion deletion, updation etc) in db.json until json server is restarted.
Now i tried POSTMAN, and i realised it's very easy and simple process to setup mockserver and create an endpoint. But is there anyway i can do PUT, POST etc to postman and save the data somewhere? like we can do in JSON server's db.json?
also is there any other advantage i can get using POSTMAN's mock server over JSON mock server?
I am new to POSTMAN's mock server so any input would be of great help
Postman Mockserver:
The response you get from the mock server is the example you store for your request.
you can hardcode the value or store the response in a variable and set example as :
Now the response you get depends on the value for the variable 'response'
make sure you select the environment for the mock server where the variable 'response' is present
Related
I'm trying to leverage Postman's mock server feature to mock an API that my application calls.
This is a Post request. I have gone through the documentation and as advised I have saved the responses as examples.
When I try hit the mock URL I get the postman error response
Here is my setup -
My Collection with saved examples
MY mock server
After going through your query, I can see that you're trying to match an example based on the body passed with the request.
To match an example based on the request body, you can leverage the body matching feature of mock servers by:
Enabling the body matching feature from the mock edit page (Reference: https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/setting-up-mock/#matching-request-body-and-headers).
OR
Passing an additional x-mock-match-request-body header with value as true along with your mock request to get the desired results.
You can find more information on how to use body matching feature with mock servers here: https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/matching-algorithm/#6-check-for-header-and-body-matching.
Do let me know if this doesn't solve your issue. In that case, it would be helpful if you can share the mock request that you're sending to get the response.
I am trying to write automated tests with Postman. I am new to postman automation world so sorry if the question will seem dumb.
In the api that I need to test when I send a request I immediately receive a response with a transactionID, no matter transaction succeeded or not. Along with my request I send a CallbackURL to the server where I expect the actual transaction result to be called back. The server will do a PUT request back to the CallbackURL that I have provided with the transactionID and the actual response or error.
So the question is, can I have such kind of scenarios in my postman tests?
I guess I should run a web server and expose an endpoint which will expect a PUT request and I should get the body of this PUT request in my tests to check it, and respond back to it with success.
In other words, within my script I need to perform the following actions:
Do a request to the server passing a callback URL
check the immediate response from the server and keep the returned transactionID
Have a webserver run with an endpoint that I passed as a callback URL
Expect a request to that endpoint with transactionID and actual response
Check that the response is what I actually expected
Respond to the request with success
I was thinking about Postman Mock server, but seems it is not designed for such usage.
I also think may be I can run some JS Webserver (may be nodeJS) inside the postman Sandbox...
Actually I am very new to postman testing and I am really confused about this kind of issue. Is it even possible to do this with postman or I need something else?
There are some features provided by POSTMAN which can help you to resolve your problem
When you do request to server passing callback URL it gives you transactionID in response. Save that transactionID in environment variable or global variable. Same you can do it for callbackURL.
Eg. pm.environment.set("transactionID", transactionID);
Then you can do the second request where you passed callback URL and transactionID which you have already.
In short in POSTMAN there are features like
Set global and environment variable which helps to pass some values fetched from response to another request.
call other request on success of first request
eg. postman.setnextRequest({{requestname}});
If you can mentioned your problem statement little bit in details it will be easy to answer in better way.
Hope This Will Help You
I am using Django, Neo4j, and pentaho. In Pentaho Data Integration, we can use the javascript for any transaction. My question is that can we call ajax from the PDI javasticpt to django server method. Actually i want to send success msg to server after the ETL process done by the PDI. Following is the javascript I am trying.
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "http://127.0.0.1/url_name/?parameter=value", false);
xhReq.send();
Don't re-invent the wheel my friend!, use the "REST Client" step as the last step of your flow, and use the parameters in the step to specify the GET Method and URL with GET parameters to send. After executing the "REST Client" you will get the expected response as you specified in the parameters (maybe a JSON if your server answers it).
You don't need to code with javascript (actually is possible with User Defined Java Class with coding, but it's a more complex process).
Can cookies be used with ember-network requests? Thanks to this answer I know that they can be used with ember-data API requests, but I need to do a network request in an initializer and it doesn't appear the ember-data store can be accessed that early.
Background:
I'm wanting to persist shopping cart data to the backend for these reasons
The ember-cart addon has a smart way of persisting the cart by jsonifying and data model and dumping to localstore when it changes:
window.localStorage.setItem('cart', JSON.stringify(this.payload()));
then upon return visit parsing the json and pushing it into the store in an instance initializer:
...
payload = JSON.parse(payload);
...
cart.pushPayload(payload);
I'd like to do basically the same thing, but instead of getting the JSON from localstorage, get it from the API via the network.
the store ins't available in an initializer, but ember-network is. So hypothetically I think I can do this. The problem I'm running into is that the cookie isn't being passed.
I get around this with ember-data by using this:
xhrFields: {
withCredentials: true
}
in the application adapter, but I can't find any info about whether there's a similar setting for ember-network. I see the request to my API being made in the initializer, but the api doesn't return anything because the browser cookie isn't included.
The fetch API provides a credentials option..
This is also documented at the whatwg-fetch library used by ember-network.
So basically you can do
fetch("/foobar", { credentials:"include" }).then(...)
I am using SoapUI to test the web service. In that I can able to format one request and get the response back.
now My requirement is I need to prepare a file(not sure about the format) and I have to send 50 to 100 different requests at a time from the soapUI client and get the response back.
Colud any one help me out in this?
You can use datasource to load the input for which you want to get back response and then loop it using datasource loop step
More info : http://www.soapui.org/Data-Driven-Testing/datasources.html
Not sure if this what you are looking for.