Definitely syntax and powershell handling. Not really a guacamole problem,
but I figured I'd ask here. Matthieu suggested a powershell module which
looks super promising.
Justin

On Mon, Aug 30, 2021 at 4:48 PM James <[email protected]> wrote:

> Actually, just goto the ui, hit f12 then add the connection. You can see
> the body and uri passed in network. Probably just a syntax error
>
> On Mon, Aug 30, 2021, 6:42 PM James <[email protected]> wrote:
>
>> When I get to work tomorrow, I'll post the snippet you need.
>>
>> On Mon, Aug 30, 2021, 6:35 PM Justin Engwer <[email protected]> wrote:
>>
>>> Hi,
>>> I'm admittedly pretty poor at JSON and Powershell. I'm hoping someone
>>> here can give me a hand. I have a script for installing and configuring VNC
>>> on a given domain PC. I'm currently attempting to write web requests to add
>>> a new connection. I have authentication working, it's just the actual
>>> creation of a new VNC connection that's broken. Keeps giving me error 500.
>>> Any suggestions?
>>>
>>> ### Add connection to guacamole WIP
>>> $pc = $args[0]
>>> [Net.ServicePointManager]::SecurityProtocol =
>>> [Net.SecurityProtocolType]::Tls12
>>>
>>>
>>> # Obtain Token
>>> $postParams = "username=api&password=aaaaaaa"
>>> $t = Invoke-WebRequest -Uri https://remoteaccess.domain.ca/api/tokens
>>> -Method POST -Body $postParams|ConvertFrom-Json | select AuthToken
>>> $token = $t.Authtoken
>>>
>>>
>>> # test thing
>>> $param = @{
>>>   parentIdentifier = "ROOT";
>>>   name = "aaaaaaaaaaaaaaa";
>>>   protocol = "vnc";
>>>   parameters = {
>>>     port = "5900";
>>>     password = "aaa";
>>>     hostname = "$pc"
>>>   }
>>> }
>>> $diet = $param | convertto-json
>>> Invoke-WebRequest -Uri "
>>> https://remoteaccess.domain.ca/api/session/data/mysql/connections?token=$token";
>>> -ContentType  "application/json" -Method POST -Body $diet
>>>
>>>
>>>
>>> # Deauthenticate token
>>> Invoke-WebRequest -Uri https://remoteaccess.domain.ca/api/tokens/$token
>>> -Method DELETE -Body "token=$token"
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> *Justin Engwer*
>>>
>>

-- 

*Justin Engwer*
Mautobu Business Services
250-415-3709

Reply via email to