Добрый день.
Где-то в темах проскакивало взаимодействие php и odata. Решил сделать свой запрос на добавление контакта, запросы кросс-доменные, пример . Авторизация проходит(code=0), но данные в bpm не добавляются. в iis 500 ошибка.
<?php
$url = "http://localhost:8001/ServiceModel/AuthService.svc/Login";
$requestData["UserName"] = "User";
$requestData["UserPassword"] = "Password";
$jcres = json_encode($requestData);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR,'cookie.txt');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jcres);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jcres))
);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
//Запрос odata
$urlGetCardInfo = "http://localhost:8001/0/ServiceModel/EntityDataService.svc/ContactCollection";
$requestDataService["Name"] = "123";
$jcres = json_encode($requestDataService);
$ch = curl_init($urlGetCardInfo);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR,'cookie.txt');
$file = "cookie.txt";
$lines = file( $file );
$str = $lines[6];
$prefix = "BPMCSRF";
$index = strpos($str, $prefix) + strlen($prefix);
$token = trim(substr($str, $index));
echo $token;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;odata=verbose',
'BPMCSRF:' . $token,
'Content-Length: ' . strlen($jcres))
);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $jcres;
echo "
";
echo var_dump($result);
?>
Куки:
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE / FALSE 0 BPMLOADER fnmuevt2z4bpsxmyookyy3g3
#HttpOnly_localhost FALSE / FALSE 0 .ASPXAUTH BCF0752E4949BD3D6EC56072B957CB5C1B9517D2F7C19B9C3F70E0BBA6ED4BD46FE55B0E90853EF5E88CD83EE9AA689C5595517AA5B7F7DF913873919C440E5ED7607A04F4C0C14D61216682067F860D1EC6DC3872811FFAF710CA7F8FC8A8B0C0F77A146D40447FBEE6629EC37546E4C7B08DAFFC8EA37F2F5D7AF522D1816B16A968A0BAAC80738D874AEE3C2A0A9730B7C7155430F3B033C6A934F56AF04FF659C62C191822CC743FEA070757841FF4C73B7FC67EFA5CE4C4B430CFA8E798B085E84BAD37C56D80FFBB9244AC5ED83DCF8052F30D442637EB668DD93B2A4C591382EC09F3A0CE8CB18C56BD327745A983E70A9D3F911439AE4173AF04849AA84713883CEB089AB5D9F89A324ADA0FC02CDA670B07FBCD0B10670FD9F6ADC8D58B7DB2E9A27CD49FE0DCB9E21AEDAD76EA95134024BACE86C9BDFAEB2A30FDC177927BFFF25A16AC80A3B37084D0D4067DBAFD992CB95E14BEC365E5CB26BA82CB393B
localhost FALSE / FALSE 0 BPMCSRF Ao/SdrXnBoquQZZ39643ue
#HttpOnly_localhost FALSE / FALSE 1526629837 UserName 83|117|112|101|114|118|105|115|111|114