diff --git a/src/PostmanConversions.js b/src/PostmanConversions.js index 545ea51..f075648 100644 --- a/src/PostmanConversions.js +++ b/src/PostmanConversions.js @@ -17,8 +17,15 @@ const requestFromLocal = (localRequest) => { let dataMode = null let rawModeData = null if (localRequest.request.body && localRequest.request.body.urlencoded) { - data = dataFromLocalURLEncode(localRequest.request.body.urlencoded) dataMode = localRequest.request.body.mode + if (dataMode === 'formdata') { + dataMode = 'params' + data = dataFromFormData(localRequest.request.body.formdata) + } else if (dataMode === 'file') { + dataMode = 'binary' + } else { + data = dataFromLocalURLEncode(localRequest.request.body.urlencoded) + } rawModeData = localRequest.request.body.raw } @@ -137,6 +144,21 @@ const dataFromLocalURLEncode = (localFormData) => { return data } +const dataFromFormData = (localFormData) => { + const data = [] + for (const param of localFormData) { + const item = { + key: param.key, + description: param.description, + value: param.value, + enabled: !param.disabled, + type: param.type + } + data.push(item) + } + return data +} + module.exports = { requestFromLocal, responseFromLocal diff --git a/src/postmanAPI.js b/src/postmanAPI.js index 7924dd2..b4f5b66 100644 --- a/src/postmanAPI.js +++ b/src/postmanAPI.js @@ -28,7 +28,7 @@ class Collection { async merge (destinationCollectionId, strategy = 'updateSourceWithDestination') { return await this.axios.post( 'https://api.getpostman.com/collections/merge', - { source: this.collectionId, destination: destinationCollectionId, strategy }, + { source: this.collectionId, destination: destinationCollectionId }, //, strategy }, { timeout: 1000 * 60 * 5 } // 5 minutes ).then(function (response) { if (response.status !== 200) { @@ -144,6 +144,7 @@ class Request { request, { params: { folder: folderId } } ).then(function (response) { + // console.log('response', response) if (response.status !== 200) { throw new Error(`Error creating request ${request.id}: ${response.status} ${response.statusText}`) } else {