Add Candidate with resume

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

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

Add Candidate with resume

Post by nitinmt » Thu Dec 04, 2008 3:32 am

My label id is 2622.
I am trying to add a candidate into bullhorn using the API. I am able to submit the candidate without resume. But when I try multipart, candidate is not going into bullhorn. I am executing following code:
package com.jdbc;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

public class URLConnectionFileUpload {

/**
* @param args
*/
public static void main(String[] args) {
HttpURLConnection conn = null;
BufferedReader br = null;
DataOutputStream dos = null;
DataInputStream inStream = null;
OutputStream os = null;
String exsistingFileName = "C:\\candidateResume.doc";
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 1*1024*1024;
String urlString = "http://www.bullhornstaffing.com/Bullhor ... lesAPI.cfm";
try
{
//------------------ CLIENT REQUEST
String encodedData = URLEncoder.encode("privateLabelID", "UTF-8") + "=" + URLEncoder.encode("2622", "UTF-8");
encodedData += "&" + URLEncoder.encode("returnToURL", "UTF-8") + "=" + URLEncoder.encode("http://www.bullhorn.com", "UTF-8");
encodedData += "&" + URLEncoder.encode("parameterPrefix", "UTF-8") + "=" + URLEncoder.encode("", "UTF-8");
encodedData += "&" + URLEncoder.encode("notify", "UTF-8") + "=" + URLEncoder.encode("3", "UTF-8");
encodedData += "&" + URLEncoder.encode("firstName", "UTF-8") + "=" + URLEncoder.encode("candidateFirstName", "UTF-8");
encodedData += "&" + URLEncoder.encode("lastName", "UTF-8") + "=" + URLEncoder.encode("candidateLastName", "UTF-8");
encodedData += "&" + URLEncoder.encode("state", "UTF-8") + "=" + URLEncoder.encode("AL", "UTF-8");

FileInputStream fileInputStream = new FileInputStream( new File(exsistingFileName) );
URL url = new URL(urlString);
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
dos = new DataOutputStream( conn.getOutputStream() );

dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"upload\";" + " filename=\"" + exsistingFileName +"\"" + lineEnd);
dos.writeBytes(lineEnd);
dos.writeBytes(encodedData);

bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
buffer = new byte[bufferSize];
bytesRead = fileInputStream.read(buffer, 0, bufferSize);

while (bytesRead > 0)
{
dos.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
fileInputStream.close();
dos.flush();
dos.close();
}
catch (MalformedURLException ex)
{
System.out.println("From ServletCom CLIENT REQUEST:"+ex);
}

catch (IOException ioe)
{
System.out.println("From ServletCom CLIENT REQUEST:"+ioe);
}


//------------------ read the SERVER RESPONSE


try
{
inStream = new DataInputStream ( conn.getInputStream() );
String str;
while (( str = inStream.readLine()) != null)
{
System.out.println("Server response is: "+str);
System.out.println("");
}
inStream.close();

}
catch (IOException ioex)
{
System.out.println("From (ServerResponse): "+ioex);

}
}

}

Please tell me where I am wrong.

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

Re: Add Candidate with resume

Post by jp.dowd » Thu Dec 04, 2008 12:48 pm

Hello Nitin,
The best way to debug problems like these are to see what the difference is between the output your application is creating and a simple html form.

Here is the method I would suggest for troubleshooting your application.
  • Download a packet capture utility, there are several good ones out there, if you are using a Microsoft environment they provide a free one called "Microsoft Network Monitor 3.2" and you can download it here: http://www.microsoft.com/downloads/deta ... laylang=en .
  • Take a copy of the generated HTML form from the Candidate Capture Tools and save it to your local machine.
  • Capture the packets that the HTML form sends to Bullhorn.
  • Capture the packets that your application sends to Bullhorn.
Usually you will be able to see the differences easily. If you have trouble seeing the differences of the captured packets you can post them to this thread and we can take a look.

J.P.

Locked