# Reuqest executing successfully in Postman but the generated code is failing

**URL:** <https://community.postman.com/t/reuqest-executing-successfully-in-postman-but-the-generated-code-is-failing/33806>\
**Category:** Help Hub\
**Created:** [March 24, 2022, 8:42am UTC](https://community.postman.com/t/reuqest-executing-successfully-in-postman-but-the-generated-code-is-failing/33806 "2022-03-24T08:42:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikharv](https://avatars.discourse-cdn.com/v4/letter/s/8e7dd6/32.png) [@shikharv](https://community.postman.com/u/shikharv)\
**Post date:** [March 24, 2022, 8:42am UTC](https://community.postman.com/t/reuqest-executing-successfully-in-postman-but-the-generated-code-is-failing/33806/1 "2022-03-24T08:42:18Z")

</div>

Hi,

I have the following 2 doubts:

1. I have a simple API request that is working as expected and I can see the output.  
However, the same generated code (PowerShell - RestMethod) is not working when I run it.

2. It’s a pretty straightforward request with a URL and APIKEY in the header. But I noticed in the request code that Postman is generating a Cookie header parameter automatically. I do not understand this.

I am attaching the screenshot of the postman request as well as the generated code.

 ![Postman Generated Code](https://us1.discourse-cdn.com/getpostman/original/2X/a/ade213cc1e597b89ccb8857df4b7aaebb35f1e7e.png)  
 ![Postman Request](https://us1.discourse-cdn.com/getpostman/original/3X/e/d/ed5087356511b3dd57dda8a28a53004924bc2c32.png)

Its been a few days that I am stuck here without any resolution and scratching my head constantly. Any pointers would be helpful.

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:** [April 29, 2025, 3:43pm UTC](https://community.postman.com/t/reuqest-executing-successfully-in-postman-but-the-generated-code-is-failing/33806/2 "2025-04-29T15:43:04Z")

</div>

Closed on April 29, 2025, 3:43pm UTC


