Hi
How do i actually send variables within the REST API that could trigger a script in the backend to create a structure based on those variables sent in the API.
I have an Endpoint with GET and PUT and have tried numerous times without success yet.
Hi This is my endpoint code:
Write-Host ($Headers[“Content-Type”])
Write-Host ($Body)
$Object = $Body | ConvertFrom-Json
“Country: ‘$($Object.Country)’”
“Function: ‘$($Object.Function)’”
“Parameter3: ‘$($Object.Parameter3)’”
Get-ADuser -Identity $Parameter3
This is my API call:
Invoke-RestMethod http://localhost:5000/api/v1/json -Method POST -Body (@{
Country = ‘Sweden’
Function = ‘FunctionName123’
Parameter3 = ‘UserName123’
} | ConvertTo-Json) -ContentType ‘application/json’
How can i actually use the variables sent to be utlized in backend code of powershell ?
Not very much for answers here but this is working now:
This is my endpoint code:
param(
[Parameter(Position=0,mandatory=$true)]
[string]$Parameter1,
[Parameter(Position=1, mandatory=$true)]
[string]$Parameter2,
[Parameter(Position=2,mandatory=$true)]
[string]$Parameter3,
[Parameter(Position=2,mandatory=$true)]
[string]$Parameter4
With psu 4.2.5 you can tag mandatory fields but it’s a bug so when you do Body will stop working.
They have added a fix to 4.2.6 that will be released soon
Okey, in what purpose are you using that if i may ask? =)
Would be interesting if the API could respond back exactly what mandatory field is missing an input as an reply to requester, maybe tags can help here.