PUT Candidate data, Where to pass SessionId?


Currently contains 3 posts


September 20, 2018 05:48


Hello I am trying to PUT candidate data using the PHP curl
URL: https://www.pcrecruiter.net/rest/api/candidates/{candidateID}

I am passing json data after /candidates/{candidateID}/{jsondata}
it is showing SessionId is missing, so in which location should I pass SessionId?

I have tried it adding after {jsondata} with & keyword, when does that is shows 404 error.

I have also tried to pass it in headers still no help.

In PCR docs it says to do post request like this:
PUT ../candidates/123123123123123

“Notes”: “These are existing Notes. \r\n These are newly added notes.”,
“Summary”: “This is existing Summary Data. \r\n This is additional Summary Data to be added”,
“Keywords”: "MGR-Sales-Existing Keyword; VP-Sales-New Keyword "

Can you let me know some reference to PHP examples so that I can better understand POST, PUT requests?


September 20, 2018 08:16


Sample code

function putCandidate($CandidateId, $FirstName, $LastName, $EmailAddress, $MobilePhone, $JobId) {
$session_id = ‘mysessionID’;

$putquerydata = array(
“FirstName” => $FirstName,
“LastName” => $LastName,
“MobilePhone” => $MobilePhone,
“HasResume” => ‘1’,
“EmailAddress” => $EmailAddress,
EEOC” => array(
“Field” => ‘source’,
“Values” => array(
“JobId” => $JobId,
“Value” => ‘HTTP_REFERER’

$puturl = ‘https://www.pcrecruiter.net/rest/api/candidates/’.$CandidateId;

$putdata = stripslashes(json_encode($putquerydata));


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $puturl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’,‘Content-Length: ’ . strlen($putdata)));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ’PUT’);
curl_setopt($ch, CURLOPT_POSTFIELDS,$putdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);

$response = curl_exec($ch);

$info = curl_getinfo($ch);





September 20, 2018 12:56


You have a couple of options here. You can include the SessionId in the URL by url encoding the value and adding it as a url parameter.
For example:

PUT ../rest/api/candidates/123123123123?SessionId=YourSessionIdURLEncodedHere

or by placing it in the header with the authorization parameter:
Authorization: BEARER YourSessionIdHere

If you are using an array you could do something like the following
$headerArray = array(‘Content-Type: application/json’,‘Accept: application/json’);
array_push($headerArray, "Authorization: BEARER " . $sessionId);

Reply to thread