Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Code generator for Powershell v5

Aperta
#501 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, powershell
Ambito
api, tooling

Direzione di ricerca

Inizia riproducendo l’upload multipart generato in PowerShell v5 usando l’esempio nell’issue, quindi confronta il suo comportamento con PowerShell v7. Il lavoro è completato quando lo script generato invia il file e le coppie chiave-valore dei form-data all’endpoint di upload indicato e il server li riceve.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

codegen

I am trying to upload a file with powershell.
To do this I used Postman (form-data) to generate a powershell script like this:

add-type -AssemblyName System.Net.Http
$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$multipartFile = 'C:\Users\hoang\Desktop\ntdll.h'
$FileStream = [System.IO.FileStream]::new($multipartFile, [System.IO.FileMode]::Open)
$fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$fileHeader.Name = "file"
$fileHeader.FileName = "/C:/Users/hoang/Desktop/ntdll.h"
$fileContent = [System.Net.Http.StreamContent]::new($FileStream)
$fileContent.Headers.ContentDisposition = $fileHeader
$multipartContent.Add($fileContent)

$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "bla"
$stringContent = [System.Net.Http.StringContent]::new("this is test")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod '172.19.183.247:5679/api/v1/upload' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

Everything looks fine (I edited the file path correctly and added System.Net.http). However on the server side I don't get any key-values or files.
After searching on google I found a workaround that is to use powershell v7. However, this version is not universal and requires additional installation.
So can you guys show me how to write a script that works with powershell v5? Or if possible, I think you guys should make postman-code-generators work with powershell v5.
Thank you very much!

Lingua principale
JavaScript
Stelle
1k
Fork
380
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di postmanlabs/postman-code-generators

Tutte le issue di postmanlabs/postman-code-generators

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.