API Method Variable

Hi Adam!

Quick one: Is there a system variable I can use in an API endpoint to find out what web method was used? I can see that an endpoint can be defined using more than one method (e.g. GET as well as POST) but is there a way from within the endpoint script that I can “know” how it was called?

Cheers,
Matt

Product: PowerShell Universal
Version: 3.1.6

Ooh I think I’ve found it! $Method does indeed seem to have the value ‘GET’ or ‘POST’ depending on how the endpoint was called. I couldn’t find that in the docs. Maybe I’m just blind. :slight_smile:

1 Like

I don’t think it’s mentioned anywhere, I ran into this a while back, but thought it was just unsupported because the Cmdlet help mentions it’s accepting only a string, so didn’t think more of it at the time.

1 Like

I’ve updated the docs to include this variable: https://docs.powershelluniversal.com/platform/variables#api-1

1 Like