# Send multipart form-data with cURL in PowerShell

Paste a curl command that sends multipart form-data and get idiomatic PowerShell code. We pick the right serialization for Invoke-RestMethod and set the correct Content-Type.

## Example

```bash
curl -X POST https://api.example.com/upload \
  -F "file=@/path/to/photo.png" \
  -F "caption=Hello"
```

## What the converter handles

- Content-Type is detected from -H headers first, then inferred from the body shape when the header is missing.
- Each -F flag becomes a distinct part; file@ paths are surfaced as Invoke-RestMethod file handles so the multipart boundary stays valid.
- Charset directives on Content-Type (e.g. application/json; charset=utf-8) survive the round trip.

## Common mistakes

- Setting Content-Type manually and then also using Invoke-RestMethod's helper — you end up with duplicate headers or the wrong one wins.
- Forgetting @ in -F "file=@upload.png" — without it curl sends the literal string, not the file. The generator flags this.
- Trusting the browser DevTools "Copy as cURL" to preserve charset — it often drops it. Clean panel restores common defaults.

## FAQ

### How is multipart form-data encoded in the generated PowerShell?

-F flags translate to multipart form-data with proper boundary handling — files={...} in Python, MultipartFormDataContent in C#, MultipartBody.Part in Java/Kotlin.

### Does it preserve Content-Type?

Yes. The Content-Type header is honored and matched against the body so serialization stays consistent.

### Is anything uploaded?

No. Parsing and generation happen entirely in your browser.

---

Source: https://toolpaper.manavdev.site/how-to/send-multipart-with-curl-in-powershell · Language hub: https://toolpaper.manavdev.site/curl-to-powershell