Ok, seems like some more troubleshooting payed out.

Seems like i missed the Accept header in the request :-)

Accept: application/json

The issue is now solved.

On Tue, Jun 21, 2016 at 3:45 PM, Orestis Tsakiridis <orestis.tsakiridis@telestax.com> wrote:
Hello,

I'm trying to update a keycloak Client using the client-registrations endpoint as described here:

http://keycloak.github.io/docs/userguide/keycloak-server/html/client-registration.html#d4e1569

All seems fine and client creation as retrieval work but *update* keeps failing.

Here is what i do:

1. Create a new bearer-only Client with ClientID -> newclient

2. I 'Regenerate registration access token' here is what i get:
eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI0MGM1ZWIyNy1mYTNmLTRiNjktYjlmZC01NTIyYWM2NzYxZDkiLCJleHAiOjAsIm5iZiI6MCwiaWF0IjoxNDY2NTExNzEyLCJpc3MiOiJodHRwOi8vMTI3LjAuMC4xOjgwODEvYXV0aC9yZWFsbXMvcmVzdGNvbW0tdGVzdCIsImF1ZCI6Imh0dHA6Ly8xMjcuMC4wLjE6ODA4MS9hdXRoL3JlYWxtcy9yZXN0Y29tbS10ZXN0IiwidHlwIjoiUmVnaXN0cmF0aW9uQWNjZXNzVG9rZW4ifQ.bI2JQLOAwWdxgtaNgAXw8aliWRJRs7RviNJRPHPHyVFI6AfuBsEpZ9c5e_v6vFD0hWoNjneUnDmS-CUrzPKcBWrITXkrUwxwEQAJpQD-ONWim6AiVVOxr3sizgwxRyBX__Cny8IMm8BWjUIIIkRviSc9QE7tYscTRTE4AP5ZRlsmB7hsmfkRSgzmd5SF2ZQWj8DriSou_-ivzZ9wnlwENoewePOK1b6oZhhGQiGo4SM0pLkTWGkN8kuO3aYei6OKiol2eJn9B4bA7wr6uUruEAg03symAaDFWscpmHIl27sxF3XkYdn8F-vJwNdhFJx_t84IEKucwZEwdgNFuWZuIQ

3. I make the update request to:

http://127.0.0.1:8081/auth/realms/restcomm-test/clients-registrations/default/newclient

here is the curl command:
 curl -i -X PUT \
>    -H "Authorization:Bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJhNDc3NzA3Yi1hOGM4LTRjMGItYjExYi0xZWE4ZTgyNTNkYTgiLCJleHAiOjAsIm5iZiI6MCwiaWF0IjoxNDY2NTEyMDc4LCJpc3MiOiJodHRwOi8vMTI3LjAuMC4xOjgwODEvYXV0aC9yZWFsbXMvcmVzdGNvbW0tdGVzdCIsImF1ZCI6Imh0dHA6Ly8xMjcuMC4wLjE6ODA4MS9hdXRoL3JlYWxtcy9yZXN0Y29tbS10ZXN0IiwidHlwIjoiUmVnaXN0cmF0aW9uQWNjZXNzVG9rZW4ifQ.G33SBIhvFay8YAMkGxeyWMDSfeM9slS7pv49hWNxmmvaNUmUOFhP8e2-WcQJW2NZEumOKSm-UGk-2VH5EiB24F8DWn9hGVOlJdIysewbyei94Xqcu-xoOAhSRdcU3xOEEKrVBQxTAQRWahp5Jil1A_jHoY1bLcQk1Keu1WAOKDBgUyGu2pO7sfs1hjUHQ2V_pC9xOeC7rf3rpdXF7OAb9Xf8pD1_xfuUwMSGJzey0Mqs3dp9qS_v4g6CaOQvcMOVgf0_cb0RKkeSyqgxcTO0Laxrz7NNP4I9ZojLQE_8bEyPQyrREfWZj8zQp4hLO89k_O_xzv3iOYOj064xiEX6nA" \
>    -H "Content-Type:application/json" \
>    -d \
> '{"clientId":"newclient","enabled":false}
> ' \
>  'http://127.0.0.1:8081/auth/realms/restcomm-test/clients-registrations/default/newclient'

4. I get a 500 Internal Server error response with the following error in the logs:

RESTEASY002005: Failed executing PUT /realms/restcomm-test/clients-registrations/default/newclient: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: org.keycloak.representations.idm.ClientRepresentation of media type: application/octet-stream

5. If i run again i get a 401 so it seems that authorization passes the first time but something breaks afterwards. Next time, the one-time token is already consumed so i get a 401. Ok, that makes sense.

As you may have noticed i'm using a pretty reduced version of the ClientRepresentation but i've also experienced with others that are more or less complete and also by sending the exact json response as returned when retrieving the client. Same result :-(

Also, the rest of the HTTP methods (POST on /default,DELETE, GET) work fine with the registration access token. So it seems that either i'm sending crap or sth else happens.

Any ideas what may be wrong?

Thanks