You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Daniel Carroll <ap...@defiant.coloradomesa.edu> on 2022/11/15 17:03:38 UTC

Guacamole REST API question/help

Hi,

I've been using Apache Guacamole for a while now and have had quite a bot of success with it.
Now I'm trying to use the Guacamole REST API to configure users and connections.
I'm able to successfully query the REST API for information, but now that I'm trying to add/update information I'm not having any success.  Would anyone be able to give me some pointers?
I'm using the official Dockerized version of Apache Guacamole 1.4.0 from DockerHub: https://hub.docker.com/r/guacamole/guacamole (and guacamole/guacd)
This Github repository documents the REST API that I'm trying to follow: https://github.com/ridvanaltun/guacamole-rest-api-documentation#api-ref

When I attempt to create a new Guacamole connection, I receiving the following generic error in the REST response:
    Unexpected internal error

I see the following in the Tomcat logs (via 'docker logs CONTAINERID'):
  ...
  15:57:19.557 [http-nio-8080-exec-3] ERROR o.a.g.rest.RESTExceptionMapper - An internal error occurred, but did not contain an error message. Enable debug-level logging for details.
  15:57:19.559 [http-nio-8080-exec-3] DEBUG o.a.g.rest.RESTExceptionMapper - Unexpected error in REST endpoint.
  java.lang.NullPointerException: null
          at org.apache.guacamole.rest.directory.DirectoryObjectTranslator.filterAttributes(DirectoryObjectTranslator.java:145)
          at org.apache.guacamole.rest.connection.ConnectionObjectTranslator.filterExternalObject(ConnectionObjectTranslator.java:68)
          ...

I tried setting the LOGBACK_LEVEL environment variable to debug when creating the docker instance and that did raise the logging level, but it hasn't provided any insight into the unhelpful "An internal error occurred, but did not contain an error message. Enable debug-level logging for details" message.
Also, per https://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-logging
I've edited logback.xml in the container and set: <appender name="GUAC-DEBUG" ... </appender> <root level="debug"> <appender-ref ref="GUAC-DEBUG"/> </root>
That didn't provide any additional logging information that I could see.

I've also captured the contents of the POST to create the connection and it looks kosher.  Here's roughly what it looks like (I've edited the token and names):

  POST /guacamole/api/session/data/mysql/connections?token=xxx...xxx HTTP/1.1
  User-Agent: Faraday v0.14.0
  Content-Type: application/json
  Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
  Accept: */*
  Connection: close
  Host: guac.my.dns.domain
  Content-Length: 230

  {"parentIdentifier":"ROOT","name":"XXXXX","protocol":"rdp","parameters":{"port":"3389","security":"nla","ignore-cert":"true","username":"${GUAC_USERNAME}","password":"${GUAC_PASSWORD}","hostname":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}


Does anyone have any thoughts/suggestions as to what I need to do differently to create connections using the REST API?
Dropping the parentIdentifier setting didn't help.
Thanks,

	- Daniel


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole REST API question/help

Posted by MOLINIE Mathieu gmail <ma...@gmail.com>.
Hi,

The only empty attribute in my json data that I am using in my script is 
this one :

{
...
     'attributes': {
         'max-connections': ''
     }
...
}

Hope it helps,

Mathieu


Le 15/11/2022 à 19:38, Daniel Carroll a écrit :
> Hi Nick,
>
> Your suggestion/pointer about using the browser to see what was being POSTed resolved my issues!
> I hadn't realized that the WebUI used the same REST interface.
> The issue was that more of the empty/blank fields also needed to be included in the POST (I included all of them).  Apparently the REST API doesn't have any internal default values and everything needs to be explicitly specified?
> Thanks again for the help.
>
> 	- Daniel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail:user-help@guacamole.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole REST API question/help

Posted by Daniel Carroll <ap...@defiant.coloradomesa.edu>.
Hi Nick,

Your suggestion/pointer about using the browser to see what was being POSTed resolved my issues!
I hadn't realized that the WebUI used the same REST interface.
The issue was that more of the empty/blank fields also needed to be included in the POST (I included all of them).  Apparently the REST API doesn't have any internal default values and everything needs to be explicitly specified?
Thanks again for the help.

	- Daniel


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole REST API question/help

Posted by Nick Couchman <vn...@apache.org>.
On Tue, Nov 15, 2022 at 12:03 PM Daniel Carroll
<ap...@defiant.coloradomesa.edu> wrote:
>
> Hi,
>
> I've been using Apache Guacamole for a while now and have had quite a bot of success with it.
> Now I'm trying to use the Guacamole REST API to configure users and connections.
> I'm able to successfully query the REST API for information, but now that I'm trying to add/update information I'm not having any success.  Would anyone be able to give me some pointers?
> I'm using the official Dockerized version of Apache Guacamole 1.4.0 from DockerHub: https://hub.docker.com/r/guacamole/guacamole (and guacamole/guacd)
> This Github repository documents the REST API that I'm trying to follow: https://github.com/ridvanaltun/guacamole-rest-api-documentation#api-ref
>

This is not an official Guacamole repository, but it's nice that
someone has taken a stab at this. There have been some efforts in the
past to try to programmatically document it - one of these days we'll
get that integrated into the project.

> When I attempt to create a new Guacamole connection, I receiving the following generic error in the REST response:
>     Unexpected internal error
>
> I see the following in the Tomcat logs (via 'docker logs CONTAINERID'):
>   ...
>   15:57:19.557 [http-nio-8080-exec-3] ERROR o.a.g.rest.RESTExceptionMapper - An internal error occurred, but did not contain an error message. Enable debug-level logging for details.
>   15:57:19.559 [http-nio-8080-exec-3] DEBUG o.a.g.rest.RESTExceptionMapper - Unexpected error in REST endpoint.
>   java.lang.NullPointerException: null
>           at org.apache.guacamole.rest.directory.DirectoryObjectTranslator.filterAttributes(DirectoryObjectTranslator.java:145)
>           at org.apache.guacamole.rest.connection.ConnectionObjectTranslator.filterExternalObject(ConnectionObjectTranslator.java:68)
>           ...
>
> I tried setting the LOGBACK_LEVEL environment variable to debug when creating the docker instance and that did raise the logging level, but it hasn't provided any insight into the unhelpful "An internal error occurred, but did not contain an error message. Enable debug-level logging for details" message.
> Also, per https://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-logging
> I've edited logback.xml in the container and set: <appender name="GUAC-DEBUG" ... </appender> <root level="debug"> <appender-ref ref="GUAC-DEBUG"/> </root>
> That didn't provide any additional logging information that I could see.
>
> I've also captured the contents of the POST to create the connection and it looks kosher.  Here's roughly what it looks like (I've edited the token and names):
>
>   POST /guacamole/api/session/data/mysql/connections?token=xxx...xxx HTTP/1.1
>   User-Agent: Faraday v0.14.0
>   Content-Type: application/json
>   Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
>   Accept: */*
>   Connection: close
>   Host: guac.my.dns.domain
>   Content-Length: 230
>
>   {"parentIdentifier":"ROOT","name":"XXXXX","protocol":"rdp","parameters":{"port":"3389","security":"nla","ignore-cert":"true","username":"${GUAC_USERNAME}","password":"${GUAC_PASSWORD}","hostname":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}
>
>
> Does anyone have any thoughts/suggestions as to what I need to do differently to create connections using the REST API?

The most likely explanation is that the body is not formatted
correctly - either the JSON is bad, or something about the headers
isn't quite right. I'd suggest using the browser's Developer Tools to
capture output during creation with the Web interface, which will give
you the headers and body format that is required to correctly create
the connection, user, etc.

-Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


RE: Guacamole REST API question/help

Posted by Sean Hulbert <sh...@securitycentric.net.INVALID>.
You can try this

curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d
'username=username&password=password' https://URLHERE
 
curl -X DELETE
https://GuacamoleServer:8080/Guacamole/api/tokens/1A065A4E9D59753CD427A03F8C
861B6D68B5CC245A75436707C66C234F8215E3
 


Thank You
Sean Hulbert
 
Founder / CEO
Work Ph: 925.663.5565
 
Security Centric Inc.
A Cybersecurity Virtualization Enablement Company
We don't just run you through the motions, Our labs teach you how to think!
 
 

System Award Management
CAGE: 8AUV4

AFCEA San Francisco Chapter V.P.
 
If you have heard of a hacker by name, he/she has failed, fear the hacker
you haven’t heard of!
 
CONFIDENTIALITY NOTICE: This communication with its contents may contain
confidential and/or legally privileged information. It is solely for the use
of the intended recipient(s). Unauthorized interception, review, use or
disclosure is prohibited and may violate applicable laws including the
Electronic Communications Privacy Act. If you are not the intended
recipient, please contact the sender and destroy all copies of the
communication. Content within this email communication is not legally
binding as a contract and no promises are guaranteed unless in a formal
contract outside this email communication.
 
igitur qui desiderat pacem, praeparet bellum!!!

Epitoma Rei Militaris

-----Original Message-----
From: Daniel Carroll [mailto:apacheguacamole0901@defiant.coloradomesa.edu] 
Sent: Tuesday, November 15, 2022 9:04 AM
To: user@guacamole.apache.org
Subject: Guacamole REST API question/help

Hi,

I've been using Apache Guacamole for a while now and have had quite a bot of
success with it.
Now I'm trying to use the Guacamole REST API to configure users and
connections.
I'm able to successfully query the REST API for information, but now that
I'm trying to add/update information I'm not having any success.  Would
anyone be able to give me some pointers?
I'm using the official Dockerized version of Apache Guacamole 1.4.0 from
DockerHub: https://hub.docker.com/r/guacamole/guacamole (and
guacamole/guacd) This Github repository documents the REST API that I'm
trying to follow:
https://github.com/ridvanaltun/guacamole-rest-api-documentation#api-ref

When I attempt to create a new Guacamole connection, I receiving the
following generic error in the REST response:
    Unexpected internal error

I see the following in the Tomcat logs (via 'docker logs CONTAINERID'):
  ...
  15:57:19.557 [http-nio-8080-exec-3] ERROR o.a.g.rest.RESTExceptionMapper -
An internal error occurred, but did not contain an error message. Enable
debug-level logging for details.
  15:57:19.559 [http-nio-8080-exec-3] DEBUG o.a.g.rest.RESTExceptionMapper -
Unexpected error in REST endpoint.
  java.lang.NullPointerException: null
          at
org.apache.guacamole.rest.directory.DirectoryObjectTranslator.filterAttribut
es(DirectoryObjectTranslator.java:145)
          at
org.apache.guacamole.rest.connection.ConnectionObjectTranslator.filterExtern
alObject(ConnectionObjectTranslator.java:68)
          ...

I tried setting the LOGBACK_LEVEL environment variable to debug when
creating the docker instance and that did raise the logging level, but it
hasn't provided any insight into the unhelpful "An internal error occurred,
but did not contain an error message. Enable debug-level logging for
details" message.
Also, per
https://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-loggi
ng
I've edited logback.xml in the container and set: <appender
name="GUAC-DEBUG" ... </appender> <root level="debug"> <appender-ref
ref="GUAC-DEBUG"/> </root> That didn't provide any additional logging
information that I could see.

I've also captured the contents of the POST to create the connection and it
looks kosher.  Here's roughly what it looks like (I've edited the token and
names):

  POST /guacamole/api/session/data/mysql/connections?token=xxx...xxx
HTTP/1.1
  User-Agent: Faraday v0.14.0
  Content-Type: application/json
  Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
  Accept: */*
  Connection: close
  Host: guac.my.dns.domain
  Content-Length: 230

 
{"parentIdentifier":"ROOT","name":"XXXXX","protocol":"rdp","parameters":{"po
rt":"3389","security":"nla","ignore-cert":"true","username":"${GUAC_USERNAME
}","password":"${GUAC_PASSWORD}","hostname":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}}


Does anyone have any thoughts/suggestions as to what I need to do
differently to create connections using the REST API?
Dropping the parentIdentifier setting didn't help.
Thanks,

	- Daniel


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org