<div dir="ltr">Thanks will try that. I can see how I got confused.<div><br></div><div>More questions to cone ...</div><div><br></div><div>However thanks for a fast response and a great product.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 13, 2015 at 7:26 AM Marek Posolda &lt;<a href="mailto:mposolda@redhat.com">mposolda@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Hi,<br>
      <br>
      I think you&#39;re supposed to send the list of roles (JSON array),
      but you&#39;re instead sending the object. I think the stuff like
      &quot;realm&quot;, &quot;id&quot; and &quot;client&quot; is not needed in your last request,
      just send the list of roles instead. <br>
      <br>
      Btv. you can take a look at docs
      <a href="http://keycloak.github.io/docs/rest-api/admin/realms/%7Brealm%7D/users/%7Bid%7D/role-mappings/clients/%7Bclient%7D/index.html#POST" target="_blank">http://keycloak.github.io/docs/rest-api/admin/realms/%7Brealm%7D/users/%7Bid%7D/role-mappings/clients/%7Bclient%7D/index.html#POST</a>
      . What should help is also to install some plugin to decode
      requests to your browser (like Firebug in Firefox) and then do
      some actions in keycloak admin console (like assign some client
      role to some user) and then analyze how the request for assign
      roles should look like, what&#39;s the format of data etc. Admin
      console is angular application, which uses REST requests to admin
      REST API under the hood.<br>
      <br>
      Marek</div></div><div bgcolor="#FFFFFF" text="#000000"><div><br>
      <br>
      On 12.8.2015 18:56, Christopher Davies wrote:<br>
    </div></div><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite">
      <div dir="ltr">I am trying to write  a test harness for out
        application which uses KeyCloak.
        <div>In order to run my tests I need to manipulate KeyCloak.</div>
        <div><br>
        </div>
        <div>I am able to get data out of KeyCloak using the REST API.
          However I am unclear what I should send to KeyCloak to change
          a setting.</div>
        <div><br>
        </div>
        <div>I was trying to set the role for a user and wrote the
          script at the bottom of the email.</div>
        <div><br>
        </div>
        <div>I get back an error of
          org.codehaus.jackson.map.JsonMappingException: Can not
          deserialize instance of java.util.ArrayList out of
          START_OBJECT token</div>
        <div> at [Source:
          io.undertow.servlet.spec.ServletInputStreamImpl@73cda37e;
          line: 1, column: 1]</div>
        <div><br>
        </div>
        <div>I have obviously missed a key point in the format of my
          data, but cannot see what it is.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Chris</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>---------------------------------------</div>
        <div>
          <div>#!/bin/bash</div>
          <div><br>
          </div>
          <div>host=<a href="http://192.168.10.221:8088" target="_blank">192.168.10.221:8088</a></div>
          <div>realm=ATS-ci</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>t=$(curl -X POST
            <a href="http://$" target="_blank">http://$</a>{host}/auth/realms/${realm}/protocol/openid-connect/token
            --data &quot;username=${1}&quot; --data &quot;password=${2}&quot; --data
            &quot;grant_type=password&quot; --data &quot;client_id=client&quot;
            2&gt;/dev/null | jq -r &quot;.id_token&quot;)</div>
          <div><br>
          </div>
          <div>client=$(curl
            <a href="http://$" target="_blank">http://$</a>{host}/auth/admin/realms/${realm}/clients -H
            &quot;Accept: application/json&quot; -H &quot;Authorization: Bearer ${t}&quot;
            2&gt;/dev/null | jq -r &quot;.[] | select(.name ==
            \&quot;client\&quot;).id&quot;)</div>
          <div>user=$(curl
            <a href="http://$" target="_blank">http://$</a>{host}/auth/admin/realms/${realm}/users -H &quot;Accept:
            application/json&quot; -H &quot;Authorization: Bearer ${t}&quot;
            2&gt;/dev/null | jq -r &quot;.[] | select(.username ==
            \&quot;${3}\&quot;).id&quot;)</div>
          <div><br>
          </div>
          <div>echo ${client}</div>
          <div>echo ${user}</div>
          <div><br>
          </div>
          <div>echo &quot;Roles&quot;</div>
          <div>curl
            <a href="http://$" target="_blank">http://$</a>{host}/auth/admin/realms/${realm}/clients/${client}/roles
            \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Accept: application/json&quot; \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Authorization: Bearer ${t}&quot; 2&gt;/dev/null  | jq -r &quot;.[] |
            {id, name }&quot;</div>
          <div><br>
          </div>
          <div>echo &quot;&quot;</div>
          <div>echo &quot;Roles:${3}&quot;</div>
          <div>curl
            <a href="http://$" target="_blank">http://$</a>{host}/auth/admin/realms/${realm}/users/${user}/role-mappings/clients/${client}
            \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Accept: application/json&quot; \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Authorization: Bearer ${t}&quot; 2&gt;/dev/null | jq -r &quot;.[] |
            {id, name }&quot;</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>curl
            <a href="http://$" target="_blank">http://$</a>{host}/auth/admin/realms/${realm}/users/${user}/role-mappings/clients/${client}
            \</div>
          <div><span style="white-space:pre-wrap"> </span>-X
            POST \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Content-Type: application/json&quot; \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Accept: application/json&quot; \</div>
          <div><span style="white-space:pre-wrap"> </span>-H
            &quot;Authorization: Bearer ${t}&quot; \</div>
          <div><span style="white-space:pre-wrap"> </span>--data
            &quot;{&#39;realm&#39;: &#39;ATS-${realm}&#39;, &#39;id&#39;: &#39;${user}&#39;, &#39;client&#39;:
            &#39;${client}&#39;, &#39;\$entity&#39;: [ &#39;operator&#39; ] }&quot;</div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </blockquote></div><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite"><pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
    </blockquote>
    <br>
  </div>

</blockquote></div>