You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Yang Yang <yy...@icloud.com.INVALID> on 2020/01/07 11:02:32 UTC

Internal Error with RESTful API

Hello,

I am trying to use the RESTful API, but got an issue at the first step :-(

I tried with curl to get a token, and get an error message telling “internal error”:

$curl -X POST -H "Content-Type: application/json" -d '{"username":"XXXXXXXX", "password":"XXXXXXXX"}' http://MY-GUACAMOLE/guacamole/api/tokens
{"message":"Unexpected internal error","translatableMessage":{"key":"Unexpected internal error","variables":null},"statusCode":null,"expected":null,"type":"INTERNAL_ERROR"}

Checking the logs, I was told “Can not deserialize instance”, as below.

10:52:17.922 [http-nio-8080-exec-3] ERROR o.a.g.rest.RESTExceptionMapper - Unexpected internal error: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token
 at [Source: org.apache.catalina.connector.CoyoteInputStream@7fe62df5; line: 1, column: 2]
10:52:17.923 [http-nio-8080-exec-3] DEBUG o.a.g.rest.RESTExceptionMapper - Unexpected error in REST endpoint.
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token
 at [Source: org.apache.catalina.connector.CoyoteInputStream@7fe62df5; line: 1, column: 2]
 at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
…


Could you help to shed some light? I can login from the web portal with the username/password.

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


Re: Internal Error with RESTful API

Posted by Yang Yang <yy...@icloud.com.INVALID>.
Thank you very much, Mike! It works now.

Thanks,
Yang


> On Jan 8, 2020, at 06:16, Mike Jumper <mj...@apache.org> wrote:
> 
> On Tue, Jan 7, 2020 at 3:02 AM Yang Yang <yy...@icloud.com.invalid> wrote:
> Hello,
> 
> I am trying to use the RESTful API, but got an issue at the first step :-(
> 
> I tried with curl to get a token, and get an error message telling “internal error”:
> 
> $curl -X POST -H "Content-Type: application/json" -d '{"username":"XXXXXXXX", "password":"XXXXXXXX"}' http://MY-GUACAMOLE/guacamole/api/tokens <http://my-guacamole/guacamole/api/tokens>
> {"message":"Unexpected internal error","translatableMessage":{"key":"Unexpected internal error","variables":null},"statusCode":null,"expected":null,"type":"INTERNAL_ERROR"}
> 
> Parameters for credentials need to be submitted as form data, not as the properties of a JSON object. Try:
> 
> curl -X POST --data-urlencode "username=XXXXXXXX" --data-urlencode "password=XXXXXXXX" http://MY-GUACAMOLE/guacamole/api/tokens <http://my-guacamole/guacamole/api/tokens>
> 
> You can also check what you're doing against what you see within browser dev tools. If you check the POST that goes to .../api/tokens when you log in within a browser, you should see that the contents of the form are submitted as form data, not JSON.
> 
> - Mike
> 


Re: Internal Error with RESTful API

Posted by Mike Jumper <mj...@apache.org>.
On Tue, Jan 7, 2020 at 3:02 AM Yang Yang <yy...@icloud.com.invalid> wrote:

> Hello,
>
> I am trying to use the RESTful API, but got an issue at the first step :-(
>
> I tried with curl to get a token, and get an error message telling
> “internal error”:
>
> $curl -X POST -H "Content-Type: application/json" -d
> '{"username":"XXXXXXXX", "password":"XXXXXXXX"}'
> http://MY-GUACAMOLE/guacamole/api/tokens
> {"message":"Unexpected internal
> error","translatableMessage":{"key":"Unexpected internal
> error","variables":null},"statusCode":null,"expected":null,"type":"INTERNAL_ERROR"}
>

Parameters for credentials need to be submitted as form data, not as the
properties of a JSON object. Try:

curl -X POST --data-urlencode "username=XXXXXXXX" --data-urlencode
"password=XXXXXXXX" http://MY-GUACAMOLE/guacamole/api/tokens

You can also check what you're doing against what you see within browser
dev tools. If you check the POST that goes to .../api/tokens when you log
in within a browser, you should see that the contents of the form are
submitted as form data, not JSON.

- Mike