Question regading usage.
Closed this issue · 2 comments
Question
I am working on a local powershell function and I want to have it available via rest.
So I I have setup everything on my windows machine with the example of this repository.
Now I wanto have my function also added. I first thought I edit RestPSRoutes.json and add a line like.
{
"RequestType": "PUT",
"RequestURL": "/newfunction",
"RequestCommand": "c:/RestPS/endPoints/GET/new-testfunction.ps1"
},
but this didn't work.
So my basic question is. How do I add my personal function. I need some guidance here I know powershell but rest is new for me.
Thanks !
First, Thanks for using the module! Second, you are correct about how to add a function.
Are you sure you have the file in the correct location? In the Request type you identified it as a 'PUT' but in the path you have a 'GET'
Ow my bad. Well eventually I created this when reading about rest and the post get put . I changed it to POST. Since I want the function to do something on the local machine when somebody hits the url. It needs to sign a file.
{
"RequestType": "POST",
"RequestURL": "/sign",
"RequestCommand": "c:/RestPS/endPoints/POST/Invoke-Sign.ps1"
},
but when I use the invoke
2020-05-08 16:01:20 INFO: Start-RestPSListener: Processing RequestType: POST URL: /sign Args:
2020-05-08 16:01:20 INFO: Start-RestPSListener: Finished request. StatusCode: 400 StatusDesc: Bad Request
I think it has to do with the invoke-sign.ps1 since it contains a function dat needed to be run. But I only declared it.
so I have the
Invoke-Sign.ps1 which contains
function Invoke-sign {
Some rubbish code ;)
}
I need to change this to pass the argument to the file.
I will check this.
Thanks for the quick response.