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

Re: Mass upload documents via API

Post by Karen.Swanson » Mon Nov 03, 2008 2:12 pm

Hi Jay
Were you able to reproduce the issue?
Thanks
Karen

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

Re: Mass upload documents via API

Post by jcraig » Mon Nov 03, 2008 4:57 pm

Karen:

I am now able to reproduce this very strange issue. I will let you know as soon as I have something. In the meantime, can you manually download the files?

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 » Mon Nov 03, 2008 5:10 pm

Hi Jay
Not really....we need this automated because of the amount of files and time constraints
Thank you

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

Re: Mass upload documents via API

Post by jcraig » Tue Nov 04, 2008 4:20 pm

Karen:

From your code, it seems you are using the StreamWriter class. I'm not a .NET developer but from what I've read this class is for writing text, not binary data. This would explain why the .rtf file (a text file) would work but not PDFs and Word docs. Please change your code to use the FileStream class instead and let me know if that works. I can replicate the same behavior in Java if I use the FileOutputStream class rather than the DataOutputStream class.

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 Nov 14, 2008 5:57 pm

Hi Jay
This is still not working for us. Perhaps we can get on the phone to discuss or you can share some code you know works please

Below is what we think is the issue
application/x-www-form-urlencoded

Here is my new coding to get file data from Bullhorn. The line in red below is were I think the problem is. I changed my code to use the FileStream class and the BinaryWriter to try to write all of the data tyo the file in binary content so DOC, PDF and other binary data will not be lost.

I think using the original coding from Bullhorn to use their web services, the content type application/x-www-form-urlencoded is returning only text. I think I need another content type(s) that will return the correct content.

GetFilePassParam="&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
Dim os As FileStream = New FileStream(PathToFiles+FileName,FileMode.Create)
Using bw As BinaryWriter = New BinaryWriter(os)
bw.Write(GetFile.responseText)
Bw.Close()
End Using
Thank you

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

Re: Mass upload documents via API

Post by jcraig » Mon Nov 17, 2008 11:53 am

Karen:

I will look for the java code I was using that worked and sent it over to you ASAP.

Thanks,
Jay

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

Re: Mass upload documents via API

Post by jcraig » Mon Nov 17, 2008 4:40 pm

Karen:

Here is the Java code I was able to use to successfully download the 5 files:

Code: Select all

URL url = new URL(urlStr);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
	        
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
int line;
String responseData = "";

File fileOut = new File(filePath);
FileOutputStream outStream = new FileOutputStream(fileOut);
DataOutputStream dataOutStream = new DataOutputStream(outStream);
System.out.print(key);

while((line=rd.read()) > 0)
{
	dataOutStream.write(line);
}
        
dataOutStream.close();
outStream.close();
wr.close();
rd.close();
If it's helpful, I can also send the Coldfusion code I was able to use to download the 5 files. It's a lot simpler.

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 » Mon Nov 17, 2008 5:09 pm

Thank you Jay
Cold Fusion would be great as well
Thank you so much

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

Re: Mass upload documents via API

Post by jcraig » Mon Nov 17, 2008 5:40 pm

Karen:

Here is the much simpler Coldfusion code. Be sure to set the 4 variables at the top (privateLabelID, encKey, userID, and fileDestination).

Code: Select all

<cfset privateLabelID = 0 />
<cfset encKey = urlEncodedFormat("xxxxx") />
<cfset userID = 0 />
<cfset fileDestination = "xxxxx">

<cfhttp url="http://www.bullhornstaffing.com/bullhornstaffing/api/GetFileListAPI.cfm?privateLabelID=#privateLabelID#&encryptedAPIKey=#encKey#&userID=#userID#" method="get">

<cfset docXML = xmlParse(cfhttp.filecontent) />
<cfset fileArray = xmlSearch(docXML,"root/fileList/userWorkFileID_INT") />

<cfset fileNameArray = xmlSearch(docXML,"root/fileList/displayName_STRING") />
<cfloop from="1" to="#arrayLen(fileArray)#" index="i">
	<cfhttp url="http://www.bullhornstaffing.com/bullhornstaffing/api/GetFileAPI.cfm?privateLabelID=#privateLabelID#&encryptedAPIKey=#encKey#&userID=#userID#&userWorkFileID=#fileArray[i].xmlText#" method="get" getasbinary="yes">
	<cffile action="write" file="#fileDestination#\#fileNameArray[i].xmlText#" output="#cfhttp.filecontent#">
</cfloop>
Thanks,
Jay

nitinmt
User
Posts: 20
Joined: Wed Nov 26, 2008 2:09 am

Re: Mass upload documents via API

Post by nitinmt » Mon Dec 08, 2008 9:25 am

Can you please send me the java code to attach the doc file using bullhorn API.


jcraig wrote:Karen:

Here is the Java code I was able to use to successfully download the 5 files:

Code: Select all

URL url = new URL(urlStr);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
	        
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
int line;
String responseData = "";

File fileOut = new File(filePath);
FileOutputStream outStream = new FileOutputStream(fileOut);
DataOutputStream dataOutStream = new DataOutputStream(outStream);
System.out.print(key);

while((line=rd.read()) > 0)
{
	dataOutStream.write(line);
}
        
dataOutStream.close();
outStream.close();
wr.close();
rd.close();
If it's helpful, I can also send the Coldfusion code I was able to use to download the 5 files. It's a lot simpler.

Thanks,
Jay

jp.dowd
User
Posts: 164
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jp.dowd » Mon Dec 08, 2008 10:29 am

Hello Nitin,
Have you been able to see the difference between what your code is posting and an html page? I posted instructions on how to see this over on this topic: http://supportforums.bullhorn.com/viewt ... 3320#p3327 for you.

Capturing packets is not a hard thing to do, and an analysis will help you debug your problem greatly. As a tool it is very useful not just for working with Bullhorn APIs but for working with all sorts of applications.


J.P.

nitinmt
User
Posts: 20
Joined: Wed Nov 26, 2008 2:09 am

Re: Mass upload documents via API

Post by nitinmt » Wed Dec 10, 2008 7:35 am

I tried capturing the packets using the utility, but I could not find any difference. Now when I try my code, I am getting error as "ELEMENT RECRUITERUSERID is undefined in FORM", but I am not able to understand that, as I am not passing the RECRUITERUSERID from my normal html form also where I am just calling bullhorn url on form action.

jp.dowd wrote:Hello Nitin,
Have you been able to see the difference between what your code is posting and an html page? I posted instructions on how to see this over on this topic: http://supportforums.bullhorn.com/viewt ... 3320#p3327 for you.

Capturing packets is not a hard thing to do, and an analysis will help you debug your problem greatly. As a tool it is very useful not just for working with Bullhorn APIs but for working with all sorts of applications.


J.P.

jp.dowd
User
Posts: 164
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jp.dowd » Thu Dec 11, 2008 10:51 am

Hello Nitin,
Could you post the captured packets? I will take a look before I get them but if it works one method and not the other then there are almost certainly differences in the data sent.

J.P.

jp.dowd
User
Posts: 164
Joined: Wed Dec 31, 1969 8:00 pm

Re: Mass upload documents via API

Post by jp.dowd » Thu Dec 11, 2008 1:51 pm

Hello Nitin,
It sounds like you could be passing the RECRUITERUSERID but without a value. If you have a recruiteruserid then you can add it but if you do not have one then you should not send the field.

Give this a try.

J.P.

nitinmt
User
Posts: 20
Joined: Wed Nov 26, 2008 2:09 am

Re: Mass upload documents via API

Post by nitinmt » Fri Dec 12, 2008 12:42 am

I am not passing RECRUITERUSERID, but I am getting return response from server "RECRUITERUSERID is undefined in FORM"

jp.dowd wrote:Hello Nitin,
It sounds like you could be passing the RECRUITERUSERID but without a value. If you have a recruiteruserid then you can add it but if you do not have one then you should not send the field.

Give this a try.

J.P.

Locked