catalogue
1.2 create request 1.3 set assertion
2.1 setting environment variables
2.1.2 setting environment variables
2.1.3 setting environment variables
2.1.5 view the value of the current environment variable
2.1.6. Set the environment variable through the value of response
2.2 set global variables 2.2.1 enter the global variables page
2.2.2 modifying global variables
2.3 environment variables and global variables
2.5.1 additional tools for encryption and decryption
1. What if the collection is deleted by mistake?
1 simple introduction
1.1 creating collections
1.2 create request
1.3 setting assertions
pm.test("Verify whether the returned status code is: 200",function(){ pm.response.to.have.status(200) }); pm.test("Verify returned status Whether it is: 200",function(){ var data = pm.response.json() pm.expect(data.status).to.eql(200); })
1.4 assembly test
1.5 export * json script
1.6 collection and sharing
Then the other party logs in to postman and sees it
1.7 authority management
Permission interpretation
https://learning.postman.com/docs/postman/collaboration/roles-and-permissions/
2 second order use
2.1 setting environment variables
2.1.1 new environment
2.1.2 setting environment variables
2.1.3 setting environment variables
2.1.4 switching environment
2.1.5 view the value of the current environment variable
2.1.6. Set the environment variable through the value of response
Then click "eyes" and you can see it
2.2 setting global variables
2.2.1 enter the global variables page
2.2.2 modifying global variables
2.3 api request
2.3.1 debugging and logs
control + alt + c
2.3.1 prepare-script
// Gets the value of the current variable console.log(pm.variables.get('access_token')) // Set the value of the current variable, which is only valid for the current request pm.variables.set('access_token','pppppppppppppppppp')
2.3 environment variables and global variables
2.3.1 priority
Data -- > local -- > environment variable -- > collections -- > Global
2.4 built in script
global variable
postman.clearGlobalVariable("variable_key"); # Set the value of the global variable postman.globals.set("variable_key","variable_value") postman.setGlobalVariable("variable_key", "variable_value"); # Gets the value of the global variable postman.globals.get("varieble_key")
collections variable
pm.collectionVariables.set("variable_key", "variable_value"); pm.collectionVariables.get("variable_key");
environment variable
# Clear an environment variable postman.clearEnvironmentVariable("variable_key"); # Set an environment variable postman.setEnvironmentVariable("variable_key", "variable_value"); pm.environment.set("variable_key", "variable_value"); # Get an environment variable pm.environment.get("variable_key");
Script current variable
pm.variables.get("variable_key");
Response content
Does it contain something
pm.response.has('string_you_want_to_search')
xml to json
var jsonObject = xml2Json(pm.response);
Direct conversion to json object
var data = pm.response.json()
Get header information
postman.getResponseHeader("Content-Type");
2.5 encryption and decryption
2.5.1 additional tools for encryption and decryption
######### Hex ######## # Get wordArray object using hexadecimal string CryptoJS.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); # wordArray to hexadecimal string CryptoJS.enc.Hex.stringify(words) Equivalent to ivWords.toString() ######### Utf8 ######## # utf8 string to wordArray CryptoJS.enc.Utf8.parse("how are you"); # wordArray to utf8 string CryptoJS.enc.Utf8.stringify(words); ######### aes ######## # encryption var cipher = CryptoJS.AES.encrypt("hello word",'123456'); console.log("cipher text",cipher.ciphertext.toString()) # decrypt var decrypted = CryptoJS.AES.decrypt(cipher,'123456'); console.log("decrypt text",decrypted.toString(CryptoJS.enc.Utf8));
2.6 documentation
2.6.1 document release
1. Create api version
2. Click "web view"
3. Click publish (the published link is visible to all)
2.7 workflow
2.7.1 postman.setNextRequest
be careful:
1. The scope of setNextRequest can only be under the same "folder" when running folder
start
1. Create 4 request s
2. Set postman setNextRequest("name")
3. Run
4. Operation results
##Frequently asked questions
1. What if the collection is deleted by mistake?
1. Click trash
2. Click the collection you want to restore
3. Select which workspace you want to restore to