hi,
I'm trying to get informations form bpm through dataservice with a php curl call, i passed the BPMCSRF in the request header , and cookies from auth as well but i'm getting 403 errors
here is my call
<?php
$url= "http://localhost/7.13.0.284_BPM_ENU/ServiceModel/AuthService.svc/Login";
$cookie_file = 'cookies.txt';
$cookies = Array();
if (! file_exists($cookie_file) || ! is_writable($cookie_file)){
echo 'Cookie file missing or not writable.';
exit;
}
$auth_arguments = array(
"UserName" => "Supervisor",
"UserPassword" => "Supervisor"
);
$auth_request = curl_init($url);
curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($auth_request, CURLOPT_HEADER, true);
curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($auth_request, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback");
curl_setopt($auth_request, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
$json_arguments = json_encode($auth_arguments);
curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments);
curl_setopt ($auth_request, CURLOPT_COOKIEJAR, realpath($cookie_file));
$result = curl_exec($auth_request);
$CSRF= explode("=",$cookies[2][1]);
$bpmcsrf=$CSRF[1];
function curlResponseHeaderCallback($ch, $headerLine) {
global $cookies;
if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
$cookies[] = $cookie;
return strlen($headerLine);
}
$urlSelect= "http://localhost/7.13.0.284_BPM_ENU/0/dataservice/json/reply/SelectQuery";
$args = array(
"RootSchemaName"=>"Product",
"OperationType"=>0,
"Columns"=>array(
"Item"=>array(
"Name"=>array(
"OrderDirection"=>Ascending,
"OrderPosition"=>0,
"Caption"=>"Name",
"Expression"=>array(
"ExpressionType"=>2,
)
)
)
),
"AllColumns"=>true,
"IsPageable"=>false,
"IsDistinct"=>false,
);
$arguments = json_encode($args);
$request = curl_init($urlSelect);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($request, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'BPMCSRF:'.$bpmcsrf,
'Content-Length:'.strlen($arguments)
));
curl_setopt($request, CURLOPT_POSTFIELDS, $arguments);
curl_setopt($request, CURLOPT_COOKIEFILE, realpath($cookie_file));
curl_setopt ($request, CURLOPT_COOKIEJAR, realpath($cookie_file));
$result = curl_exec($request);
var_dump($result);
//$products= json_decode($result,true);
?>
thanks in advance,