Disable collection pre-request script at request level - postman

I have a test collection in postman. I have a pre-request script to be run at the Collection level, but there are specific requests in the collection where I'd like the pre-request script not to run.
I can't find a way to do this; does anybody know if this is possible, and how?
Thanks in advance!

You cannot do it, but as a workaround just add a condition for collection script like:
if (pm.info.request !== "the request you want to skip") {
}
If you want to do it dynamically, then you have to do it from the request running before the request you want to skip:
eg:
request 1:
pm.variable.set("skip", true) // to skip request 2
in request 2:
pm.variable.set("skip", false ) // to ensure remaining requests don't skip collection script
and in collection add
if (!pm.variable.set("skip")) {
//then execute
}

Related

Setting timeout for postman collections

I want to run the Postman collection with timeout enabled at the collection level.
Is this setting possible at the collection level in Postman?
I know that the timeout can be set per request using setTimeout(() => {}, 15000), but I could not find something similar to run the collections.
Request timeout for single call
Postman has a setting that you set manually in Settings > General > Request timeout in ms that you can set if you want to set an explicit timeout. However, you won’t be able to do what you’re trying to do from a script.
You can, however, write request tests to make sure your response times
are under a certain threshold. That way when you run the request, the
test will fail if it’s slower than say, 800ms:
pm.test("Response time is less than 800ms", function () {
pm.expect(pm.response.responseTime).to.be.below(800);
});
According to https://community.postman.com/t/request-timeout-for-single-call/6881/2

How to send back end request in Postman in a loop

I am very new in using Postman. So please forgive me if this question is very naive to be asked in here.
I have a back end request that I want to repeat 1000 times. I have copied cURL the request from fire fox debugger tool / network tab and imported it in to postman.
Now instead of pushing send 1000 time I want to right an script to do it in post man. Do I put that script in pre-request script or test tab? after I wrote my script how do I run it?
Some thing like following : where get is the name of the request that I have saved.
for (i = 0; i < 10; i++) {
postman.setNextRequest("get");
}

Disable requests in postman collection run

I have 100 request in collection runner and there are some request that will execute only on some condition. Actually when we run the postman collection it will execute all request 1 by 1.
In my case there are 10 requests in collection runner and dont want to execute it in normal follow only trigger some request just on specific condition. Is there any why I can prevent these request not no execute in normal run but should available in collection runner will execute on just specific condition
In my opinion you can achieve this already.
I will user some flag set in environment variables to check if it is your "normal" run or not
And next use this flag in test script to set next request to be called:
if (pm.environment.get("normal_run"))
postman.setNextRequest("Request name 10");
else
postman.setNextRequest("Request name 13");
And set this part of code in every request before request you need to be skipped.
postman.setNextRequest() is executed in the end of request call, so you can place it anywhere in Pre-request Script.
Finally, use one environment for your normal run, and second environment for another.

Status Code validator in Web service consumer in mule

I have three questions...
Just like HTTP requester in mule we have success code validator , i want same for web service consumer so that in response if i am getting status code 500 , i want to make it as success scenario ( means it is consider as success state).
Also if i want to increase response time out for web service consumer in mule how can i achieve it??
Suppose i am using scatter and gather and inside there i placed 3 separate flows , at the end i know scatter-gather will respond as an array than i have to write below logic in Mel expression..how i can do that please advice.
Logic:- if payload[1] && payload[1] && payload[2] == null that return "myvalue" else default payload
Can you please answer for all three question ..
Cheers,
b
If you're getting failure response, your exception flow will be triggered.
You can use catch inside choice strategy and catch a relevant exception and set payload inside catch accordingly.
You can proxy your consumer, or your can use deprecated HTTP connector connection configuration, see this.
https://docs.mulesoft.com/mule-user-guide/v/3.8/web-service-consumer#proxy-the-web-service-consumer
Looks like you want to use if-else condition, for one can use a Groovy script or Choice router.
Hope this helps.
Cheers!

On server processing

I have a web application that will be doing some processing with submitted data. Instead of making the user wait for what will take at least a few seconds, maybe up to a few minutes during heavy load, I would like to know if there is some way to, within coldfusion, have processing that just occurs on the server.
Basically, the data would be passed to the server, and then the user would be redirected back to the main page to allow them to do other things, but not necessarily be able to see the results right away. Meanwhile, the processing of the data would take place on the server, and be entered into the database when complete.
Is this even possible within coldfusion, or would I need to look into using code that would receive the data and process it as a separate program?
ColdFusion 8 introduced the cfthread tag which may assist you.
<cfthread
required
name="thread name"
optional
action="run"
priority="NORMAL|HIGH|LOW"
zero or more application-specific attributes>
Thread code
</cfthread>
To do this reliably, you can use a database table as a job queue. So you when the user submits the data you insert record into the database indicating there is some work to be done. Then you create a scheduled task in the CF Administrator that polls a script that gets the next job from the queue and does the processing you describe. When complete it can update the database and you can then alert your user that there job is complete.
Make sense?
Another option that will possibly work for you is to use AJAX to post the data to the server. This is a pretty easy method to use, since you can use pretty much the exact same CF code that you have now and instead only need to modify the form submitting page (and you could even use some unobtrusive javascript techniques to have this degrade gracefully if javascript isn't present).
Here's an example using jQuery and BlockUI that will work for unobtrusively-submitting any form on your page in a background thread:
<script>
$(function () {
$("form").on("submit", function (e) {
var f = $(this);
e.preventDefault();
$.ajax({
method: f.attr("method"),
url: f.attr("action"),
data: f.serialize(),
beforeSend(jqXHR, settings) {
f.blockUI({message: "Loading..."});
},
complete(jqXHR, textStatus) {
f.unblockUI();
},
success: function (data, textStatus, jqXHR) {
// do something useful with the response
},
error: function(jqXHR, textStatus, errorThrown) {
// report the error
}
});
});
});
</script>
You should combine all three of these answers to give yourself a complete solution.
Use CF Thread to "kick off" the work.
Add a record to the DB to tell you the process is underway.
Use Ajax to check the DB record to see if the work is complete. When
your thread completes update the record - Ajax finds the work
complete and you display some message or indicator on the user's
screen so they can go on to step 2 or whatever. So each of these
answers holds a clue to a complete solution.
Not sure if this should be an answer or a comment (since I'm not adding anything new here).
We use an CF event gateway for this. The user submits a file via a web form and the event gateway monitors that upload directory. Based upon the file name the gateway knows how it should process the file into the database. This way the only real delay the user faces is the time for the file to actually transmit from their machine up to the server. We however have no need to inform the user of any statuses related to the process though could easily see how to work that into things if we did.