Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sean O'Connor
    Assistance with Taleo Business Edition REST API - RESUME...
    Topic posted September 4, 2019 by Sean O'Connor, tagged REST 
    29 Views, 1 Comment
    Title:
    Assistance with Taleo Business Edition REST API - RESUME Attachment
    Summary:
    Taleo Business Edition REST API - RESUME Attachment
    Content:

    Hello Oracle User Community -

     

    Regarding the Taleo Business Edition REST API documented here:  https://www.oracle.com/technetwork/documentation/tberestapiguide-v15b1-2665296.pdf

     

    In particular, we're having issues using the RESUME Attachment end point.

     

    As outlined in the above documentation:

     

    Update a candidate resume

    POST /candidate/{id}/resume

    The update will replace the old attachment with the new attachment and description. Using “multipart/form-data” POST request.

    Optional request parameter: description If the request parameter description is not sent, the attachment entity description field will use the file name as the description.

    Example:

    http method POST

    https://stgweb1.tbetaleo.com/QANA3/ats/api/v1/object/candidate/82/resume

    Header must include: {:file=>#,:multipart=true}

    For additional information about multipart/form-data, refer to mutilpart/form-data specification (www.w3.org). http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

    Example header for posting a Word attachment or resume:

    {:file => File.new(“/local/path/zip/resume.doc”, ‘rb’), :content_type => “application/msword”, :multipart => true}, {:cookies => {:authToken => “webapi26117672355175654454”}})

     

    We are having difficulty with the specification above for the headers. 

     

    Does anyone have a working client program that can be shared to assist us in determining the proper header configuration?  Doesn't matter what language or platform, we can decipher it from any example code.

     

    Here is an example of how we are currently constructing the client in Java.  This request is currently returning a 200 response (success) but the resume is not showing up on the candidate profile;  additionally, there is no additional json payload from the endpoint to help detail the call.  Thank you for any insights, sample code or ideas.

     

       public static void postResume(String authToken) throws IOException {

        // Connect to the web server endpoint

        URL serverUrl = new URL("https://chp.tbe.taleo.net/object/candidate/<candidateid>/resume");

        HttpURLConnection urlConnection = (HttpURLConnection) serverUrl.openConnection();

        

        String boundaryString = "*****" + Long.toString(System.currentTimeMillis()) + "*****";

        String fileUrl = "C:/_resume/resumeTest.docx";

        File resume = new File(fileUrl);

        

        // Indicate that we want to write to the HTTP request body

        urlConnection.setDoOutput(true);

        urlConnection.setRequestMethod("POST");

        urlConnection.addRequestProperty("Content-Type", utf8("multipart/form-data; boundary=" + boundaryString));  

        urlConnection.addRequestProperty("File", utf8(fileUrl + ", content_type=application/msword, multipart=true"));

        urlConnection.addRequestProperty("Cookie", utf8(authToken));

        urlConnection.setUseCaches(false);

        urlConnection.setDoOutput(true);

        urlConnection.setDoInput(true);

        

        OutputStream outputStreamToRequestBody = urlConnection.getOutputStream();

        BufferedWriter httpRequestBodyWriter = new BufferedWriter(new OutputStreamWriter(outputStreamToRequestBody));

        

        httpRequestBodyWriter.write(utf8("\n\n--" + boundaryString + "\n"));

        

        // Write the actual file contents

        FileInputStream inputStreamToLogFile = new FileInputStream(resume);

        

        int bytesRead;

        byte[] dataBuffer = new byte[1024];

        while((bytesRead = inputStreamToLogFile.read(dataBuffer)) != -1) {

            outputStreamToRequestBody.write(dataBuffer, 0, bytesRead);

        }

        

        outputStreamToRequestBody.flush();

        

        // Mark the end of the multipart http request

        httpRequestBodyWriter.write(utf8("\n--" + boundaryString + "--\n"));

        httpRequestBodyWriter.flush();

        

        // Close the streams

        outputStreamToRequestBody.close();

        httpRequestBodyWriter.close();

      

        // Read response from web server, which will trigger the multipart HTTP request to be sent.

        System.out.println(urlConnection.getResponseCode());

        BufferedReader httpResponseReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));

        String lineRead;

        while((lineRead = httpResponseReader.readLine()) != null) {

            System.out.println(lineRead);

        }  

      

    Version:
    19C

    Comment

     

    • Sean O'Connor

      Based on some research, it appears the request payload must be formatted in JSON.

      The Header section seems pretty straight forward and can be coded as:  

      String header = "{\"file\": \"" + fileUrl + "\", \"content_type\": \"application/msword\",  \"multipart\": \"true\", \"cookies\": {\"authToken\": \"" + authTokenValue + "\"}}";

      My question is how should the binary file attachment content be formatted in JSON?  Is there a "fileData" attribute that goes along in the header or seperately?