I wanted to pass my values to salesforce api. I am fetching the loan application number as you can see in last line of error. But it also showing "failed with status 200". Is their something to change in code or it just fine to have it. And I also wanted to display that Loan application number on frontend. What will be the syntax for it. I have already tried with array syntax of php but it wont work. Error is as following
Error: call to URL https://cs31.salesforce.com/services/apexrest/CreateLoan/ failed with status 200, response HTTP/1.1 200 OK Date: Tue, 01 Mar 2016 12:31:56 GMT Set-Cookie: BrowserId=cLMf4KPnTvqxcif286fSRQ;Path=/;Domain=.salesforce.com;Expires=Sat, 30-Apr-2016 12:31:56 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked "success: Loan Application Number - 804326966", curl_error , curl_errno 0
My code is as following
<?php session_start();
$json=$_SESSION['json'];
$details=json_decode($json);
//var_dump($details);
$name='LoanCreationService';
$instance_url='https://cs31.salesforce.com/services/apexrest/CreateLoan/';
$access_token = $details->{'access_token'};
$message=create_account($name, $instance_url, $access_token);
//echo $message->{'message'};
function create_account($name, $instance_url, $access_token) {
$url = $instance_url;
//$content = json_encode(array("Name" => $name));
$content=$_SESSION['content'];;
//echo $content;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token",
"Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$json_response = curl_exec($curl);
//echo $json_response;
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
//echo "HTTP status $status creating account<br/><br/>";
curl_close($curl);
$response = json_decode($json_response, true);
echo $id = $response["id"];
return $id;
}
?>