Attaching Resume to Candidate SOLVED

Forum for users and developers of Bullhorn's new REST API service.

Moderators: StaffingSupport, s.emmons, BullhornSupport

robotjosh
User
Posts: 4
Joined: Tue May 20, 2014 5:49 pm

Attaching Resume to Candidate SOLVED

Postby robotjosh » Thu May 22, 2014 10:14 am

I've beaten my head against a brick wall for a good three weeks on this.
Finally solved. This works great for me. Hope it helps you.

$data = "file/Candidate/".$information."/raw?externalID=Portfolio&fileType=SAMPLE&BhRestToken=".$BhRestToken;

$source_location = $filePath;
$file = $fileNameSubID.'-'.$fileName;
$post = file_get_contents(''.$source_location.$file.'');
$eol = "\r\n";
$separator = ''.md5(microtime()).'';
$requestBody = '';
$requestBody .= '--'.$separator. $eol;
$requestBody .= 'Content-Disposition: form-data; name="resume"; filename="'.$file.'"'. $eol;
$requestBody .= 'Content-Length: "'.strlen($post).'"'. $eol;
$requestBody .= 'Content-Type: text/html'.$eol;
$requestBody .= 'Content-Transfer-Encoding: binary'. $eol. $eol;
$requestBody .= ''.$post.''. $eol;
$requestBody .= '--'.$separator.'--'. $eol . $eol;

$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, $BhURL.$data);
curl_setopt($tuCurl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data; boundary='.$separator.''));
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($tuCurl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $requestBody);
$tuData = curl_exec($tuCurl);

curl_close($tuCurl);
return $tuData;

mavieo
User
Posts: 11
Joined: Mon Apr 10, 2017 2:01 pm

Re: Attaching Resume to Candidate SOLVED

Postby mavieo » Fri Apr 14, 2017 11:04 am

I have beaten my head against this for a while too. I was attempting to base64 encode it, and BH just wouldn't decode.

Added "Content-Length: 123" header and changed "Content-Transfer-Encoding: base64" to "Content-Transfer-Encoding: binary" and voila, everything works as expected.

The give away should've been that BH didn't know what to do w/ the base64 data... Thanks again.


Return to “REST API”

Who is online

Users browsing this forum: No registered users and 1 guest