0
0
Postmantesting~10 mins

Importing and exporting collections in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import a Postman collection from a JSON file.

Postman
pm.collection.import([1]);
Drag options to blanks, or click blank then click option'
AfilePath
BexportedCollection
CcollectionData
DjsonFile
Attempts:
3 left
💡 Hint
Common Mistakes
Using the collection data object instead of the file path.
Passing an undefined variable.
2fill in blank
medium

Complete the code to export the current Postman collection as a JSON object.

Postman
const exported = pm.collection.[1]();
Drag options to blanks, or click blank then click option'
Asave
BtoJSON
Cexport
Ddownload
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that saves or downloads instead of converting to JSON.
Calling a non-existent method.
3fill in blank
hard

Fix the error in the code to correctly export a collection to a file.

Postman
pm.collection.export([1]);
Drag options to blanks, or click blank then click option'
Acallback
BcollectionName
CfilePath
Doptions
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a file path string instead of a callback function.
Omitting the callback argument.
4fill in blank
hard

Fill both blanks to import a collection and then log its name.

Postman
pm.collection.import([1]).then(collection => {
  console.log(collection.[2]);
});
Drag options to blanks, or click blank then click option'
AfilePath
Bid
Cname
DjsonData
Attempts:
3 left
💡 Hint
Common Mistakes
Using JSON data instead of file path for import.
Logging the collection id instead of the name.
5fill in blank
hard

Fill all three blanks to export a collection, convert it to a string, and save it to a file.

Postman
pm.collection.[1](collection => {
  const jsonString = JSON.[2](collection);
  saveToFile(jsonString, [3]);
});
Drag options to blanks, or click blank then click option'
Aexport
Bstringify
C'collection.json'
DtoJSON
Attempts:
3 left
💡 Hint
Common Mistakes
Using toJSON instead of stringify.
Not providing a filename string for saving.