<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Re: Problem with jbpm-console (business-central) in BRMS server
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/MohReece">Maurice de Chateau</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/796892#796892">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi Jose,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Maybe not the answer to the question you're asking, but it may be one that addresses your problem: you <span style="text-decoration: underline;">can</span> access the Business Central REST API, but it's a little 'tricky' to getting around the form authentication to get there.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When you first access the API with e.g. the Apache DefaultHttpClient, the response will contain the HTML containing the form. Upon that response, you need to POST the credentials:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">
        final DefaultHttpClient httpClient = new DefaultHttpClient();
        final String url = BUSINESS_CENTRAL_REST_BASE_URL + RESOURCE_PATH + "/j_security_check";
        final List<NameValuePair> formParms = new ArrayList<NameValuePair>();
        formParms.add(new BasicNameValuePair("j_username", BUSINESS_CENTRAL_USER_NAME));
        formParms.add(new BasicNameValuePair("j_password", BUSINESS_CENTRAL_PASSWORD));
        String responseString = null;
        try {
            final HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(formParms, "UTF-8"));
            final HttpResponse response = httpClient.execute(httpPost);
            responseString = EntityUtils.toString(response.getEntity());
            EntityUtils.consume(response.getEntity());
        } catch (final Exception e) {
            e.printStackTrace();
        }
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When this returns with an HTTP 200 response you can retry your original request - which should succeed.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Basically, this is the same scenario that a browser goes through in the case of form authentication. Now one can certainly argue that this kind of authentication doesn't belong on a (true) REST interface, as it relies on server state (you only log in once per session, and the server remembers your credentials for that session) which goes against REST's principle of stateless-ness. But I guess for now we just have to make do with the implementation the Business Central server is providing us...</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/796892#796892">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>