I can start the process using an external REST client (HttpRequestor) with the same credentials I'm using in the Perl code. However, the REST client doesn't seem to need a "security realm" parameter. My suspicion is that either I've not identified what that security realm value is or it's not configured in JBoss.
Leaving this parameter blank and just providing the credentials in the LWP::UserAgent object doesn't work either.
The only only theory I have is that some REST clients throw the same error if I'm not actually logged into the Camunda GUI via a web browser. This could be an artifact of the REST client itself (i.e. it's using browser cookies). However, logging into Camunda via a web browser and then executing the Perl code does not solve the problem.
Here's the code, which was derived from other code I wrote to talk to ActiveVOS via SOAP. I'm not an experienced Perl programmer and I pretty sure that I've done something ignorant here and just can't see it. I've examined the contents of the userAgent object prior to sending the request and they seem correct.
# - Instantiate a user agent
my $userAgent = LWP::UserAgent->new(agent => 'perl get');
# - Set the user agent credentials for Camunda
$userAgent->credentials("$restHost:$restPort", "$restSecurityRealm", "$restUser", "$restPassword") ;
# - Don't require hostname verification for SSL because we don't have
# a real certificate
$userAgent->ssl_opts(verify_hostname => 0 ) ;
# - Execute the REST call
my $requestType = lc $restVerb ;
my $restResponse = $userAgent->$requestType($restUrl,Content_Type => $restContentType, Content => $restPayload) ;
I’m trying it with both as well as trying the Perl REST::Client module instead of the LWP::UserAgent module.
Using a URL of ‘engine-rest/engine/default/process-definition/count’ in the REST::Client code produces the same result. Here’s that code:
my $restClient = REST::Client->new(host => $restProtocol . "://" . $restHost . ":" . $restPort);
my $encoded_auth = encode_base64("$restUser:$restPassword", '');
$restClient->GET('/engine-rest/engine/default/process-definition/count',
'',
{'Authorization' => "Basic $encoded_auth",
'Content-Type' => 'application/json',
'Accept' => 'application/json'}) ;
print 'Response: ' . $restClient->responseContent() . "\n" ;
I took this code from some examples I found on the web. Where the raw request seems to differ with that sent by a standalone REST client (which works with either REST API end point), is that the standalone REST client seems to be sending a “Username” value in the request. In the code above, this user name and the password are base64 encoded and sent that way, though I’m not 100% sure what is being received on the JBoss server itself.
What is so frustrating here is, I know I can access the REST API with the standalone REST client, I just can’t determine what is different between it’s message and that sent by the Perl code such that JBoss rejects it.
Michael Peoples (mp4783)
Global Customer Service Dev Ops
Office: +1 614-886-0923
Mobile: +1 614-886-0923
Principal Applications Developer
--
You received this message because you are subscribed to a topic in the Google Groups "camunda BPM users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/camunda-bpm-users/JskerWPzQ78/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
camunda-bpm-us...@googlegroups.com.
To post to this group, send email to
camunda-...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/camunda-bpm-users/2fd9ea0e-23cd-4703-9763-95c7300ed539%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/env perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->credentials("localhost:8080", "default", "demo", "demo");
# get process instance countmy $response = $ua->get('http://localhost:8080/engine-rest/engine/default/process-instance/count');print $response->decoded_content . "\n";
# start process instancemy $json = '{"variables": { "amount": { "value": "100", "type": "Integer"}, "invoiceCategory": {"value": "Misc", "type": "String"}}}';my $req = HTTP::Request->new('POST', $uri);$req->header( 'Content-Type' => 'application/json' );$req->content( $json );
$response = $ua->request($req);print $response->decoded_content . "\n";
# get process instance count$response = $ua->get('http://localhost:8080/engine-rest/engine/default/process-instance/count');print $response->decoded_content . "\n";#!/usr/bin/env perl
use REST::Client;use MIME::Base64;
my $client = REST::Client->new({ host => 'http://localhost:8080' });
my $encoded_auth = encode_base64('demo:demo');
$client->addHeader('Authorization', "Basic $encoded_auth");
# get process instance count$client->GET('/engine-rest/engine/default/process-instance/count');print $client->responseContent(). "\n";
# start process instancemy $uri = '/engine-rest/engine/default/process-definition/key/invoice/start';my $json = '{"variables": { "amount": { "value": "100", "type": "Integer"}, "invoiceCategory": {"value": "Misc", "type": "String"}}}';
$client->POST($uri, $json, { "Content-Type" => "application/json" });print $client->responseContent(). "\n";
# get process instance count$client->GET('/engine-rest/engine/default/process-instance/count');print $client->responseContent(). "\n";Thank you, thank you, thank you, a million times, thank you!!
This worked. I was able to modify it to suit my needs and it starts the workflow.
Michael Peoples (mp4783)
Global Customer Service Dev Ops
Office: +1 614-886-0923
Mobile: +1 614-886-0923
Principal Applications Developer
From: camunda-...@googlegroups.com [mailto:camunda-...@googlegroups.com] On Behalf Of Sebastian Menski
Sent: Monday, February 29, 2016 2:51 PM
To: camunda BPM users
Cc: PEOPLES, MICHAEL P
--
You received this message because you are subscribed to a topic in the Google Groups "camunda BPM users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/camunda-bpm-users/JskerWPzQ78/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
camunda-bpm-us...@googlegroups.com.
To post to this group, send email to
camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/854ae5e1-db98-4ba3-97c3-a24d4a7a7244%40googlegroups.com.