“Simply create this JSON Object”
I’m lost how and what do do at that step. What JSON object?
Here is an example function I created that checks Epicor credentials that works:
//This function will call a REST service on Epicor10 and check if the user+pass combo supplied by the user is legit
function check_epicor_credentials($username = "", $password = "") {
//initialize the return value
$valid_credentials = false;
//Needed inside the HTTPHEADER Authorization parameter
//Authorization is the base64 encoded string of "username:password"
$auth = base64_encode("manager:manager");
//Start CURL
$curl = curl_init();
//Set CURL Options
curl_setopt_array($curl, array(
CURLOPT_URL => "https://our-E10-server/E10Train/api/v1/Ice.BO.UserFileSvc/ValidatePassword",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST =>false,
CURLOPT_ENCODING => "UTF-8",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\r\n \"userID\": \"". $username. "\",\r\n \"password\": \"" . $password . "\"\r\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic " . $auth,
"Cache-Control: no-cache",
"Content-Type: application/json",
),
));
//Run CURL
if ( !$c_response = curl_exec($curl) ) {
//CURL call error
//echo curl_error($curl);
$valid_credentials = false;
} else {
//CURL call success
$s = json_decode($c_response, true);
$valid_credentials = ($s['returnObj']); //returnObj is what the REST function returns, values of this are true or false
}
//Close CURL
curl_close($curl);
return ($valid_credentials);
} //end function check_epicor_credentials
I don’t know where the POST fields go or how to package them to send to CURL. The example on the API shows a huge list of items as well, how do I generate those?