Mass upload documents via API

Have a question about Bullhorn's HTTP based APIs? You've found the right place.

API Update [posted on December 13, 2012]:

This version of the Bullhorn APIs should no longer be used.

All new work should be done using Bullhorn's REST or Web Services APIs. For more information please visit: http://developer.bullhorn.com/documentation

Bullhorn REST API provides a simpler and faster way for developers to build applications that interact with the Bullhorn platform and is used by Bullhorn Inc. to develop features of the Bullhorn ATS/CRM application.

Of the BullhornSTAFFING HTTP API interfaces listed below, our analysis shows that the following are most commonly used by developers:

Resume Parsing API
Published Job Data (XML)
The interface to these will continue to work as is because Bullhorn will replace the back end to use REST API. The URLs for these 2 specific APIs may change in the 2nd half of 2013; developers may require to update their applications to use the new URLs.

Moderators: StaffingSupport, s.emmons

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Mass upload documents via API

Post by Karen.Swanson » Tue Oct 21, 2008 5:18 pm

We are trying to automatically retrieve documents attached to a candidates profile based on passing over the Candidate ID and then extracting all the documents linked to that candidate. How ever it forces a response everytime so has to have manual involvement. Can this be done without having the manual interface?

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Wed Oct 22, 2008 11:26 am

Karen:

My understanding is you are passing the candidateID to the GetFileListAPI.cfm, retrieving the documents attached to this candidate, then invoking GetFileAPI.cfm manually to get each of the files. It should, however, be rather simple to write a script to parse the XML returned from the GetFileListAPI.cfm, loop over the userWorkFileID values returned, and get the content for each file by invoking GetFileAPI.cfm within each iteration. This will return the content for each file attached to the given user and at this point in your script you can do whatever you'd like to with the file data (e.g. save it to your local file system).

Please let me know if I can be of further assistance.

Jay Craig

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Sun Oct 26, 2008 12:51 pm

Hi
We were able to sucessfully get the list of documents and return one via the API but once we found a candidate that had 5 docs the first one came over OK but the rest (PDF and doc) were truncated and unablee to be opened
any idea on what we can to insure they all come over sucessfully please
Thank you

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Mon Oct 27, 2008 12:03 pm

Karen:

My guess is that you are retrieving the file contents via an HTTP call and saving them as a string and then trying to save that string to the file system. The string will only save the data up to the first zero byte character, however, so I think this is causing the truncation you're seeing. If this is the case, try writing the file stream directly to the file instead. I have tested this approach and the entire files are saved as expected.

Jay

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Mon Oct 27, 2008 3:38 pm

Hi Jay

Here is the code...we are not saving them as a string but perhaps you can see what we are missing


GetFilePassParam="&profileType='candidate'&outputType='BHXML'&userWorkFileID="+WorkFileID+"&userID="+CandidateNumber
GetFile.open(CallType, GetFileURL, False)
GetFile.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
GetFile.send("privateLabelID=" + PrivateLabelID + "&encryptedAPIKey=" + encryptedAPIKey + GetFilePassParam)
FileName="F"+CandidateNumber+"_"+WorkFileID+"_"+Format(FileCnt,"####0")+FileExt
Using sw As StreamWriter = New StreamWriter(PathToFiles+FileName)
sw.Write(GetFile.responseText)
sw.Close()
End Using

Thank you again

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Tue Oct 28, 2008 10:17 am

Karen:

I can see from your code that you are closing the StreamWriter (sw.Close()). When you do this within a loop and there are multiple files, are you closing the StreamWriter after each iteration? If not, this maybe causing the truncation.

Jay

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Tue Oct 28, 2008 11:48 am

Hi
Here is the code to write to the file
The code to write to the file:

Using sw as StreamWriter = New StreamWriter(PathToFiles+FileName)
sw.Write(responseText)
sw.Close()
End Using

This code is within a subroutine, Executes the API, opens a New StreamWtiter, writes the responseText received from the API and then closes the file. The next time we enter the subroutine, we open another New StreamWriter, write, close and so forth until all files are processed.

Thank you

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Tue Oct 28, 2008 12:58 pm

Hi Jay
The candidate is 504201

There is 5 different docs..1 RTF, 1 Doc and 3 PDF
The RTF is fine, the Doc returns a certain amount of characters and crashes. The 3 PDFs...2 are different sizes when they come over and one is the same but none came be opened ..Adobe says it cannot be opened..the file is damaged and cannot be repaired

We tried the 3 different responses and the only that returned anything that can be used or seen is the response text.
Hopefully that helps

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Tue Oct 28, 2008 6:04 pm

Karen:

I'm going to spend some more time trying to replicate this issue. I will let you know what I find tomorrow.

Jay

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Tue Oct 28, 2008 7:03 pm

Thank you

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Wed Oct 29, 2008 7:13 pm

Karen:

I wanted to let you know that I'm still working on trying to replicate your issue. I will get back to you as soon as I have something.

Thanks,
Jay

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Thu Oct 30, 2008 6:27 pm

Karen:

Can you send the XML that is returned from the getFileListAPI call? That will contain the fileIDs for the given user (#504201) and will help troubleshoot. Also, what URL are you using in your scripts when you call the APIs?

Thanks,
Jay

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Fri Oct 31, 2008 8:27 am

API to retrieve list
http://www.bullhornstaffing.com/bullhor ... istAPI.cfm

XML results from API
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <root>
- <fileList>
<userWorkFileID_INT>58040</userWorkFileID_INT>
<displayName_STRING>Victoria Johnson.rtf</displayName_STRING>
<dateAdded_DATE>2008-10-21 10:16:42.64</dateAdded_DATE>
<type_STRING>Original Resume</type_STRING>
<fileExtension_STRING>.rtf</fileExtension_STRING>
<fileSize_STRING>22587</fileSize_STRING>
</fileList>
- <fileList>
<userWorkFileID_INT>58041</userWorkFileID_INT>
<displayName_STRING>Victoria_Client_MA</displayName_STRING>
<dateAdded_DATE>2008-10-21 10:17:29.41</dateAdded_DATE>
<type_STRING>Blind Resume</type_STRING>
<fileExtension_STRING>.doc</fileExtension_STRING>
<fileSize_STRING>63488</fileSize_STRING>
</fileList>
- <fileList>
<userWorkFileID_INT>58062</userWorkFileID_INT>
<displayName_STRING>VictoriaJohnson_HSDiploma</displayName_STRING>
<dateAdded_DATE>2008-10-21 11:07:39.173</dateAdded_DATE>
<type_STRING>Certificate/License/Diploma</type_STRING>
<fileExtension_STRING>.pdf</fileExtension_STRING>
<fileSize_STRING>23681</fileSize_STRING>
</fileList>
- <fileList>
<userWorkFileID_INT>58121</userWorkFileID_INT>
<displayName_STRING>VictoriaJohnson_LtrofRec_Gandianco</displayName_STRING>
<dateAdded_DATE>2008-10-21 13:34:04.347</dateAdded_DATE>
<type_STRING>Reference Letter</type_STRING>
<fileExtension_STRING>.pdf</fileExtension_STRING>
<fileSize_STRING>33683</fileSize_STRING>
</fileList>
- <fileList>
<userWorkFileID_INT>58122</userWorkFileID_INT>
<displayName_STRING>VictoriaJohnson_LtrofTermination_ParkMedicalCtr</displayName_STRING>
<dateAdded_DATE>2008-10-21 13:36:23.637</dateAdded_DATE>
<type_STRING>Other</type_STRING>
<fileExtension_STRING>.pdf</fileExtension_STRING>
<fileSize_STRING>28447</fileSize_STRING>
</fileList>
</root>

API to retrieve the file contents
http://www.bullhornstaffing.com/bullhor ... ileAPI.cfm

jcraig
User
Posts: 26
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jcraig » Fri Oct 31, 2008 4:26 pm

Karen:

When I run the API for user 504201, I am only seeing 1 document. Are you sure this is the correct userID?

Thanks,
Jay

Karen.Swanson
User
Posts: 80
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by Karen.Swanson » Fri Oct 31, 2008 4:29 pm

540201 is the candidate with 5 docs

Locked