Reuqest executing successfully in Postman but the generated code is failing


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.

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