Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/targets/powershell/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
allHeaders,
}) => {
const { push, join } = new CodeBuilder();
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];

if (!methods.includes(method.toUpperCase())) {
return 'Method not supported';
}
const methods = [
'DEFAULT',
'DELETE',
'GET',
'HEAD',
'MERGE',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE'
];
const methodArg = methods.includes(method.toUpperCase()) ? '-Method' : '-CustomMethod';

const commandOptions = [];

Expand Down Expand Up @@ -65,7 +73,7 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
commandOptions.push(`-Body '${postData.text}'`);
}

push(`$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`);
push(`$response = ${command} -Uri '${fullUrl}' ${methodArg} ${method} ${commandOptions.join(' ')}`);
return join();
};
return convert;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Method not supported
$response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Method not supported
$response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND