Skip to content

Commit

Permalink
fix form-data and binary body params missing
Browse files Browse the repository at this point in the history
  • Loading branch information
barduinor committed Jun 17, 2024
1 parent d81baf0 commit 1e43d36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/PostmanConversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/postmanAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1e43d36

Please sign in to comment.