Hot answers tagged

7

I am not sure what you want to do, if you are able to extract the access_token then i believe that you know to use the test script session in postman Assuming you have the access_token stored in environmental variable swt: you can use the below code in the same post request after you have stored the jwt to variable: (Keep this code in "Tests" tab ...


5

As @Mache says, you search for each value. var jsonData = pm.response.json(); pm.test("Verify Json values", function () { pm.expect(jsonData.data.id).is.to.equal(2); pm.expect(jsonData.data.first_name).is.to.equal("Janet"); pm.expect(jsonData.data.last_name).is.to.equal("Weaver"); // and so on and so on }); The better option: Create ...


4

You need to provide token generated create Token API here in header under cookie field. and URL used in not as mentioned in API https://restful-booker.herokuapp.com/booking/{bookingID} Please check the screenshot here.


4

👍Pros of coding: You can easily integrate your test into CI process You can code any assertion logic you need in your tests You can utilize any library that is suitable for your chosen coding platform You can flexibly manage your test data You can build whatever test report you want 👎Cons of coding: It requires coding skills 👍...


3

Mohamed's step will allow you to do what you wanted, but if you are trying to debug something then postman already have the postman console for this purpose. so just use console.log() in the prerequisite or test script session and open view>show postman console in the postman menu bar. Now run the request and you can see that the value is printed in the ...


3

This is interesting, Newman and the collection runner are behaving differently. I have raised a bug on postman for this : https://github.com/postmanlabs/postman-app-support/issues/8024#issue-562149355 So coming to your question : To run from collection runner wrap double-quotes between double quotes: user,pass """something""","""something""" To run ...


3

Newman has an option to select the environment you want to use, the flag -e Then, you can run newman run mycollection.json -e serviceAEnv to run the suite with the environment for service A. Then you can create a script to run many of these commands: declare -a arr=("serviceAEnv" "serviceBEnv" "serviceCEnv") for i in "${arr[@]}" do eval "newman run ...


3

I believe this is not Postman issue. You should check what proxy are you using since the header is likely added there (after the request is leaving your Postman app). I tested Postman with Wiremock and what wiremock logs showed was: Where I pointed out the header that I explicitly set for my request. Other ones were set by Postman defaults. As you can see ...


3

ReSharper is just an IDE for C# by JetBrains. This won't help you much unless you want to write everything from scratch. Postman has the ability to generate code snippets for various languages and frameworks, including C# (using RestSharp as REST/HTTP client). Consequently, you should be able to simply "convert" your requests to C#. (Haven't tried this ...


3

In overall it looks more a question regarding the code-based vs tool-based testing. And for the low-level, technology facing tests, such as integration tests, the code-based approach would give you: A little bit more overhead while writing the tests. You'll have to write the code itself (obviously), and potentially manually write mocks for the components ...


3

Don't focus too much on tooling. Tools will go out of fashion. Perhaps not this year, not in 2 years, but definitely a few times during your career life (provided you are not at the end of it, but have, say, 5+ year ahead). Here are some points along which you might want to explore: what an API is and what we're trying to achieve with it what problems web ...


2

Well it is an era of API Testing, Rest APIs in particular. I would recommend you to know the basics of Restful before you proceed to testing of different sorts. Some basics that you need to learn before you plunge into Rest API testing: Basic restful Architecture and how it functions. HTTP methods like POST, PUT and others along with their meaning HTTP ...


2

Try https://www.mockable.io There is a free plan that will allow you to build your own REST and Soap services and that will be enough to practice your interaction trials.


2

Please try without parsing, Like below var body = JSON.parse(responseBody); var content = responseBody; tests["Response Body"+content]= body.length != 0


2

Hi you should first parse the schema to json, else it will be considered as empty data in some cases. The correct code is as below: let jsonData = JSON.parse(responseBody); schema = JSON.parse(schema); Now you have to pass recursive validation and nondefined property check to the tv4.validation function. pm.test('Response schema type nodes ...


2

Your testing is good. You are considering different possibilities and conducting experiments to see what happens. That is great. I would continue that process. Here are some thoughts for you to try out. They are not answers you can copy and paste (which, as you indicate is good), they are ideas for your to try out yourself. Good luck! Try special ...


2

For functional API testing you can consider using SoapUI, it provides unlimited workspaces/projects and immense features list even for open-source free version including assertions, mocks, scripting, automation, support of OAuth and WS Security, SAML, NTLM, security testing features, limited load testing features, support of SOAP, REST, AMF, MQTT, JDBC, JMS, ...


2

Add the following code to the "Tests" script for your authentication request. This script is executed upon receipt of the response. Modify the parts in <> to match the response given. var jsonData = JSON.parse(responseBody); postman.setEnvironmentVariable("cookie", jsonData.<path_to_your_cookie>); postman.setEnvironmentVariable("xsrf", jsonData.&...


2

Problem THe send requests work asynchronously and hence get resolved only at the end, so to avoid this, use set time out, Whichever functions that use the specific collection variable, wrap it with set time out. Fix: if(pm.variables.get("drawingmanage") == 'true'){ var stat=true; modelid.map((data)=>{ data....


2

Assuming that you want to print a data from the response value var jsonData = pm.response.json(); var testmessage=jsonData._data[0].UserName //Dev_demo_82 pm.test(testmessage, function () { //testscript }); Response value of Property UserName will be stored in variable testmessage now your test name will be displayed as shown in image below


2

https://github.com/postmanlabs/newman#newman-options This gives the entire command-line options for Newman so you can use --global-var "<global-variable-name>=<global-variable-value>" to override global variable values. As we know the precedence of variables is as follows: (Precedence increase top to button , meaning local> has more ...


2

Welcome. You need to read the documentation in detail, it shows an example of a request body for PUT method: { "name":"test1", "salary":"1123", "age":"23" } There is no employee_ in the names of the attributes. So an example flow could look like this: 1) create an employee with POST ...


2

I used to write integration tests in Postman and after a couple of tens of requests, it became very difficult to maintain. Mostly because: accessing other resources like a DB was hard it was hard to separate test data from actual requests it was a bit harder and definitely more criptic to use a data driven approach you still need to use the GUI interface in ...


2

The answer depends on many other factors including the infrastructure. Even POST requests can create unwanted changes in production DB so GET is mostly the only safe method, investigate if this is the case for your product. Do you have a staging server where you do rest of the use cases (if you plan to use only POST and GET in production) What is your team ...


2

I need to check if the “dna” contains at least 10 “Ngg” sites. That means if there are a minimum of 10 [acgt]gg sites (agg or cgg or tgg or ggg). How do I write a test for that? You need to first find all such occurences: resultArray = [...dna.matchAll(/[acgt]gg/g)] then you need to assert the length: pm.test('Number of occurences if equal or greater than ...


2

I need to check if the “dna” contains at least 10 “Ngg” sites. That means if there are a minimum of 10 [acgt]gg sites (agg or cgg or tgg or ggg). How do I write a test for that? pm.test('length validation', function () { pm.expect((pm.response.json().dna.match(/[acgt]gg/g) || []).length).to.be.greaterThan(10) }); Is the following test for validating ...


1

405 shows that the specific HTTP Method is not supported for the specified endpoint. It have nothing to do with a certificate. You are using POST method on a .html file which most probably ain't supported. Change it to request.get()


1

For your needs the best tool is Swagger Swagger - here you can check how the API page will look like


1

This what the Postman variables do, Assuming that your response data is: { name: "something" user:{ id:"12" } } in the test script section, add below command let jsonData = JSON.parse(responseBody); pm.environment.set("id", jsonData.user.id) //this stores the id to env variable 'id' now you can access the id value from the next ...


1

- Is it really happening because of x-www-form-urlencoded? If so, why then we are able to get 200 Ok with teststudent@skyeng.ru and any other real email? it seems that it's a bug with the way the url encoded data is being decoded in your test product. For example consider the below comment https://github.com/angular/angular/issues/18261#...


Only top voted, non community-wiki answers of a minimum length are eligible