API Key encrypted issue

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
imdev
User
Posts: 6
Joined: Fri Jul 25, 2008 9:23 am

API Key encrypted issue

Post by imdev » Fri Jul 25, 2008 9:44 am

I have 8 set of privateLabels and APIKey. I use the following sample code I found in this forum to get basic XML format output.

Code: Select all

string appURL = "http://www.bullhornstaffing.com/BullhornStaffing/API/PublicJobPostingsXML.cfm";
        string strPostData = "privateLabelID=0000&encryptedAPIKey=keynumber";

        System.Net.HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as System.Net.HttpWebRequest;
        wrWebRequest.Method = "POST";
        wrWebRequest.ContentLength = strPostData.Length;
        wrWebRequest.ContentType = "application/x-www-form-urlencoded";
        wrWebRequest.CookieContainer = new CookieContainer();
        wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

        // Post to the login form.
        StreamWriter swRequestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
        swRequestWriter.Write(strPostData);
        swRequestWriter.Close();

        // Get the response.
        HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();

        //Have some cookies.
        CookieCollection ccCookies = hwrWebResponse.Cookies;

        // Read the response
        StreamReader srResponseReader = new
        StreamReader(hwrWebResponse.GetResponseStream());
        string strResponseData = srResponseReader.ReadToEnd();
        srResponseReader.Close();

        // Display the response.
        
        Response.Write(strResponseData);
5 of them works, 3 of them results in page with error message as following: Error: Invalid encryptedAPIKey.

Then I tried all 8 set of keys in testing page, http://www.bullhornstaffing.com/Bullhor ... MLTest.cfm, it seemed they all worked.

So I assume that those 3 non-working keys were actually encrypted (or not encrypted?), so they changed to something else when they load into the page from the code above.

I want to know what the best solution to get these 3 keys work. Should I get new set of keys?

Thanks!

cseibert
Bullhorn Employee
Posts: 392
Joined: Wed Dec 31, 1969 8:00 pm

Post by cseibert » Mon Jul 28, 2008 9:30 am

You need to URL encode all the keys before the post them. Actually, you should be URL encoding all the parameters.

imdev
User
Posts: 6
Joined: Fri Jul 25, 2008 9:23 am

Post by imdev » Mon Jul 28, 2008 11:45 am

I tried something like this

Code: Select all

string strPostData = String.Format("privateLabelID={0}&encryptedAPIKey={1}", Server.UrlEncode("LabelID#"), Server.UrlEncode("APIKey#"));
It didn't say Invalid encryptedAPIKey this time, but no data get populated. Can you show me the correct URL encoding function I should use?

Thank you,

cseibert
Bullhorn Employee
Posts: 392
Joined: Wed Dec 31, 1969 8:00 pm

Post by cseibert » Mon Jul 28, 2008 12:09 pm

That looks correct to me. If you're not getting the API key error, then the encoding is working.

Do you get results back on the test page with the same data?

cseibert
Bullhorn Employee
Posts: 392
Joined: Wed Dec 31, 1969 8:00 pm

Post by cseibert » Mon Jul 28, 2008 12:09 pm

If the jobs are not flagged as public, this could be why you are not getting any results.

imdev
User
Posts: 6
Joined: Fri Jul 25, 2008 9:23 am

Post by imdev » Mon Jul 28, 2008 12:46 pm

Yes, the set of key didn't get any result in my page had result in Bullhorn testing page, http://www.bullhornstaffing.com/Bullhor ... MLTest.cfm.

So if the jobs are not flagged as public, is there anything in coding that I can make them as public, or client has to do some config changes in their end?

cseibert
Bullhorn Employee
Posts: 392
Joined: Wed Dec 31, 1969 8:00 pm

Post by cseibert » Mon Jul 28, 2008 12:54 pm

The best method is to have the client manually update their existing jobs to be public. Bullhorn Support can also set it up so that new jobs are automatically public.

Locked