<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta content="text/html; charset=utf-8">
</head>
<body>
There is an exception in the server log, but it is not thrown, so I am not getting it in my code.
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>-------- Original message --------</div>
<div>From: Stian Thorgersen &lt;sthorger@redhat.com&gt; </div>
<div>Date: 5/27/16 09:24 (GMT&#43;02:00) </div>
<div>To: Haim Vana &lt;haimv@perfectomobile.com&gt; </div>
<div>Cc: Marek Posolda &lt;mposolda@redhat.com&gt;, keycloak-user@lists.jboss.org </div>
<div>Subject: Re: [keycloak-user] How to create the same client (same id) for multiple realms programmatically
</div>
<div><br>
</div>
<div>
<div dir="ltr">Do you not get a error when trying to create it the second time with the same id? If not please create a jira.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 26 May 2016 at 20:20, Haim Vana <span dir="ltr">&lt;<a href="mailto:haimv@perfectomobile.com" target="_blank">haimv@perfectomobile.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div bgcolor="white" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Thanks for your reply.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">My problem was that I have used setId instead of setClientId.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d"><u></u>&nbsp;<u></u></span></p>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:windowtext">From:</span></b><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:windowtext"> Marek Posolda [mailto:<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>]
<br>
<b>Sent:</b> Thursday, May 26, 2016 4:16 PM<br>
<b>To:</b> Haim Vana &lt;<a href="mailto:haimv@perfectomobile.com" target="_blank">haimv@perfectomobile.com</a>&gt;;
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<b>Subject:</b> Re: [keycloak-user] How to create the same client (same id) for multiple realms programmatically<u></u><u></u></span></p>
</div>
</div>
<div>
<div class="h5">
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">You can use for example:<u></u><u></u></p>
<pre style="background:white"><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">RealmResource realm1 = </span><b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif; color:#660e7a">adminClient</span></b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">.realms().realm(</span><b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif; color:green">&quot;realm1&quot;</span></b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">);<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">RealmResource realm2 = </span><b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif; color:#660e7a">adminClient</span></b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">.realms().realm(</span><b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif; color:green">&quot;realm2&quot;</span></b><span style="font-size:9.0pt; font-family:&quot;DejaVu Sans Mono&quot;,serif">);<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:11.5pt; background:#e4e4ff">realm1</span><span style="font-size:11.5pt">.clients().create(clientRepresentation);<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:11.5pt; background:#e4e4ff">realm</span><span style="font-size:11.5pt">2.clients().create(clientRepresentation);<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:11.5pt"><u></u>&nbsp;<u></u></span></pre>
<p class="MsoNormal"><br>
For update you can take a look at some of our tests, which are updating client. For example this one :
<a href="https://github.com/mposolda/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ClientTest.java#L183" target="_blank">
https://github.com/mposolda/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ClientTest.java#L183</a><br>
<br>
Note that you need to know client Id (this is different thant clientId). The easiest is to set it manually in representation before you create client (via client.setId ) like it's done in this test.<br>
<br>
Marek<br>
<br>
On 26/05/16 14:54, Haim Vana wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Any idea regarding the below ?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">As a workaround how can I update existing client programmatically ? I couldn't find it in the admin API.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Thanks again,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Haim.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif"> Haim Vana
<br>
<b>Sent:</b> Thursday, May 26, 2016 2:17 PM<br>
<b>To:</b> <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<b>Subject:</b> How to create the same client (same id) for multiple realms programmatically
</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">I am trying to create the same client for many realms, however it creates it only once, probably because they have the same id, however in UI I am able to create
 it.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">Any idea how I can create the same client for different realms programmatically with the same id ?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif; color:#1f497d">This is my code sample:</span><u></u><u></u></p>
<pre style="background:white"><span style="font-size:11.5pt">ClientRepresentation clientRepresentation = </span><b><span style="font-size:11.5pt; color:navy">new </span></b><span style="font-size:11.5pt">ClientRepresentation();<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:11.5pt">clientRepresentation.setId(clientId); // Same clientId for all reamls</span><u></u><u></u></pre>
<p class="MsoNormal" style="background:white"><span style="font-size:11.5pt">realm</span><span style="font-size:11.5pt; font-family:&quot;Courier New ;color:black&quot;,serif">.clients().create(clientRepresentation); // Client is created only for first realm</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif">Any advice will be appreciated,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:&quot;Calibri&quot;,sans-serif">Haim.</span><u></u><u></u></p>
<p class="MsoNormal">The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this
 message is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately
 by replying to the message and deleting it from your computer. Thank you. <br>
<br>
<br>
<u></u><u></u></p>
<pre>_______________________________________________<u></u><u></u></pre>
<pre>keycloak-user mailing list<u></u><u></u></pre>
<pre><a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><u></u><u></u></pre>
<pre><a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><u></u><u></u></pre>
</blockquote>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
</div>
</div>
<div>
<div class="h5">The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this message
 is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by
 replying to the message and deleting it from your computer. Thank you. </div>
</div>
</div>
<br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote>
</div>
<br>
</div>
</div>
The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this message is not the
 intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by replying to
 the message and deleting it from your computer. Thank you.
</body>
</html>