Hi,
I am trying to attach a file (simple text resume) to a candidate using this url:
https://rest5.bullhornstaffing.com/rest ... ype=Resume
I am using PUT method and writing the file as a byte array to the request stream.
I am getting InternalServerError {500} exception thrown...
I am using .NET as a development environment.
I would appreciate any help in pointing out what I am doing wrong...
Thanks,
Mike
attaching resume to a candidate
Moderators: StaffingSupport, s.emmons, BullhornSupport
Re: attaching resume to a candidate
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title></head>
<body>
<form id="form1" method="put" enctype="multipart/form-data" action="https://rest5.bullhornstaffing.com/rest ... ype=SAMPLE" >
<div>
<input type="file" name="resumeFile" />
<br />
<input type="submit" name="button" value="Attach" />
</div>
</form>
</body>
</html>
I get 400 error bad request.
Any help would be much appreciated
Mike
<head><title></title></head>
<body>
<form id="form1" method="put" enctype="multipart/form-data" action="https://rest5.bullhornstaffing.com/rest ... ype=SAMPLE" >
<div>
<input type="file" name="resumeFile" />
<br />
<input type="submit" name="button" value="Attach" />
</div>
</form>
</body>
</html>
I get 400 error bad request.
Any help would be much appreciated
Mike
-
- User
- Posts: 11
- Joined: Fri Dec 12, 2014 11:56 am
Re: attaching resume to a candidate
Any luck guy with these issue? on .NET framework.
thx
thx
Re: attaching resume to a candidate
Unfortunately i could not get it to work, had to use SOAP APIs instead
-
- User
- Posts: 67
- Joined: Thu Feb 20, 2014 4:52 pm
Re: attaching resume to a candidate
I couldn't get the /raw method to work either so we used the Base64 string method. Here is what we currently use to attach a resume to an existing candidate (.Net 4.5):
The FileUpload object is just a class containing the properties required in the /put/file method for the api.
It looks like this:
The request uri ends up looking like this:
https://rest.bullhorn.com/rest-services ... {restToken}
Code: Select all
public async Task<bool> UploadResume(int candidateId, byte[] resume, string fileName, string fileExtension, string description)
{
var upload = new FileUpload();
upload.FileContent = Convert.ToBase64String(resume);
upload.ExternalID = "portfolio";
upload.Name = fileName;
upload.FileType = "SAMPLE";
upload.Description = description;
upload.Type = "Resume";
switch (fileExtension)
{
case ("doc"):
upload.ContentType = "application/msword";
break;
case ("docx"):
upload.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
break;
case ("pdf"):
upload.ContentType = "application/pdf";
break;
case ("txt"):
upload.ContentType = "text/plain";
break;
case ("rtf"):
upload.ContentType = "application/rtf";
break;
case ("odt"):
upload.ContentType = "application/odt";
break;
case ("html"):
upload.ContentType = "text/html";
break;
case ("htm"):
upload.ContentType = "text/html";
break;
default:
upload.ContentType = "text/plain";
break;
}
var token = await OAuthProvider.GetRestToken();
var restToken = token["token"];
var restUrl = token["url"];
var requestUri = new StringBuilder(restUrl);
requestUri.Append(string.Format("file/Candidate/{0}?", candidateId));
requestUri.Append(string.Format("&BhRestToken={0}", restToken));
using (var client = new HttpClient())
{
var response = await client.PutAsJsonAsync(requestUri.ToString(), upload);
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
var error = string.Empty;
if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
{
var apiError = await response.Content.ReadAsAsync<ApiError>();
error = apiError.ConvertDetailToString();
}
else
{
error = await response.Content.ReadAsStringAsync();
}
throw new Exception(string.Format("Unable to attach resume to candidate: {0}", error));
}
}
}
It looks like this:
Code: Select all
public class FileUpload
{
[JsonProperty("externalID")]
public string ExternalID { get; set; }
[JsonProperty("fileContent")]
public string FileContent { get; set; }
[JsonProperty("fileType")]
public string FileType { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("contentType")]
public string ContentType { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
}
https://rest.bullhorn.com/rest-services ... {restToken}