PUT /file (request)

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

Moderators: StaffingSupport, s.emmons, BullhornSupport

fjdev1
User
Posts: 7
Joined: Wed Jan 10, 2018 2:38 pm

PUT /file (request)

Postby fjdev1 » Fri Jan 12, 2018 5:18 pm

Hello all,
Any help or advice would be extremely appreciated; allow me try to give a detailed overview:

I am attempting to send a PUT request through the Bullhorn API to associate a file with a Candidate entity. I am having trouble with this specific API endpoint - I am able to successfully make PUT requests for the creation of Candidate entities using entity/Candidate, and I'm successful in sending PUT requests to create JobSubmission entities associated with these Candidate entities. But I am unable to send through the PUT /file requests to associate uploaded documents to the Candidate entities. So, to my understanding, it's not an issue of failing authorization, but rather preparing an acceptable PUT request. Whether it's using the appropriate headers, passing appropriate data, or something or something entirely different, i'm currently at a loss. Would be extremely appreciative of another set of eyes and any insight into the functionality of the Bullhorn PUT /file operation. Many thanks in advance!

I will include my PUT request message below (corpToken replaced, and BhRestToken changed slightly):

Code: Select all

PUT /rest-services/{corpToken}/file/Candidate/208304/raw?externalID=Portfolio&fileType=SAMPLE HTTP/1.1
Content-Length: 0
User-Agent: GuzzleHttp/6.2.1 curl/7.35.0 PHP/5.6.31-4+wpengine10
Host: rest34.bullhornstaffing.com
BhRestToken: 17e759e6-99c8-6a59-87f4-d2d048c96433
Content-Type: multipart/form-data; boundary=gc0p4Jq0M2Yt08jU534c0p


Response:

Code: Select all

< HTTP/1.1 400 Bad Request
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 12 Jan 2018 21:04:12 GMT
< Connection: close


PHP error:

Code: Select all

{"errorMessage":"No File Uploaded!!","errorMessageKey":"errors.noFileInRequest","errorCode":400}


Here is some of the PHP code, to provide some insight into how the Request is being created:

Code: Select all

   $query_url = "file/Candidate/" . $newCandidateID . "/raw?externalID=Portfolio&fileType=SAMPLE";
   $options = [
      'multipart' => [['name'      => $file_name, 'contents'  => fopen($file_path,'r')]],
      'headers'   => ['Content-Type' => 'multipart/form-data; boundary=gc0p4Jq0M2Yt08jU534c0p']
   ];
   $bullhorn_helper = BullhornOAuthHelper::Singleton();
   $token = $bullhorn_helper->bullhorn_access_token();
   $request = $bullhorn_helper->provider()->getAuthenticatedRequest('PUT', $query_url, $token, $options);
   $client = new Client(['http_errors' => false, 'debug' => true]);
   $response = $client->send($request);

srg.bdavis
User
Posts: 67
Joined: Thu Feb 20, 2014 4:52 pm

Re: PUT /file (request)

Postby srg.bdavis » Tue Jan 30, 2018 2:04 am

From the looks of your code and the response, the api is unable to pull anything out of the form request. I currently use the Base64 method of the PUT request without any issues so you might give this a try:

1. Use the form to post the file to your server.
2. Convert the file data to a base64 string then construct your PUT request to the Bullhorn API.

Also, I would try setting the value of your externalID as "portfolio" in case it is case sensitive. I doubt it is, but its worth a second look.

fjdev1
User
Posts: 7
Joined: Wed Jan 10, 2018 2:38 pm

Re: PUT /file (request)

Postby fjdev1 » Thu Feb 08, 2018 6:25 pm

Thank you for the helpful advice! I actually ended up doing this before reading your response, but I can verify that this is an effective method, in case others stumble across this in the future. Now I am trying to parse the uploaded files into candidate data.... oh boy!


Return to “REST API”

Who is online

Users browsing this forum: No registered users and 4 guests