# PowerShell - RestMethod Code snippet doesn't work

**URL:** <https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716>\
**Category:** Help Hub\
**Tags:** snippet\
**Created:** [August 19, 2024, 6:47pm UTC](https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716 "2024-08-19T18:47:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![osiuser](https://avatars.discourse-cdn.com/v4/letter/o/dec6dc/32.png) [@osiuser](https://community.postman.com/u/osiuser)\
**Post date:** [August 19, 2024, 6:47pm UTC](https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716/1 "2024-08-19T18:47:58Z")

</div>

Hi guys,

I use PowerShell - RestMethod Code Snippet to get PoserShell code.

But it doesn’t work.

Below is what concerns me:

- The code doesn’t include **Content-Type** to the header if it’s set 
- The code uses the below

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()  
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new(“form-data”)  
$stringHeader.Name = “solutionName”  
$stringContent = [System.Net.Http.StringContent]::new(“SK”)  
$stringContent.Headers.ContentDisposition = $stringHeader  
$multipartContent.Add($stringContent)

to create “multipart/form-data” but I don’t see correct body in Fiddler, just

System.Net.Http.StringContent

Thanks

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 20, 2024, 8:40am UTC](https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716/2 "2024-08-20T08:40:34Z")

</div>

Hey @osiuser 👋

Could you raise a new issue on the code generators repo, please?

> **[Issues · postmanlabs/postman-code-generators](https://github.com/postmanlabs/postman-code-generators/issues)**
>
> Common repository for all code generators shipped with Postman - Issues · postmanlabs/postman-code-generators

---

<div class="post-metadata">

**Author:** ![osiuser](https://avatars.discourse-cdn.com/v4/letter/o/dec6dc/32.png) [@osiuser](https://community.postman.com/u/osiuser)\
**Post date:** [August 22, 2024, 1:12pm UTC](https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716/3 "2024-08-22T13:12:08Z")

</div>

Thanks @danny-dainton I’ve logged [PowerShell - RestMethod Code snippet doesn’t work · Issue #763 · postmanlabs/postman-code-generators · GitHub](https://github.com/postmanlabs/postman-code-generators/issues/763)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [September 21, 2024, 1:12pm UTC](https://community.postman.com/t/powershell-restmethod-code-snippet-doesnt-work/66716/4 "2024-09-21T13:12:43Z")

</div>

Closed on September 21, 2024, 1:12pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
