Table of Contents
Formatting the request
If you need to send an outbound request out of Integration Center with a content type of multipart/form-data, there are two ways that you can format the request. Regardless of which option you choose, the follow formatting rules apply:
- Add a content-type header with value
multipart/form-data; boundary=<string>(replacing<string>with any string value of your choice). - Each time you use the boundary value in the payload, it must be prefixed with 2 dashes (which are not included in the content-type header).
- The ending boundary value must also be suffixed with 2 dashes (in addition to being prefixed with 2 dashes, per rule #2).
Resume files
Sending a resume file via a multipart/form-data encoded request requires sending a binary file (not a base64-encoded string). To include a resume file in a multipart/form-data request in Integration Center, click here.
- Input the above mapped value (this is used to assign the correct content-type based on the file extension of the resume - see line 3 in the code snippet below).
- Add the following Jinja to the very beginning of the payload in Integration Center (adding these in the middle of the payload will throw off the spacing and cause the request to fail):
{%- set file = __long_id | get_resume_filename -%}
{%- set extension = (file or '').split('.')[-1].upper() -%}- Add the resume file field mapping like so (replace
name="resumeFile"with the correct field name used by the system’s API):
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="resumeFile"; filename="{{__long_id|get_resume_filename}}"
Content-Type: {{ extension | mapvalue('doc-content-type', 'plain/text') }}
{{__long_id|get_binary_resume_content}}
--WebKitFormDataBoundary492Examples
Here is an example of each option, making a POST /opportunity request into Lever.
The content-type header in both examples is multipart/form-data; boundary=WebKitFormBoundary492
Option 1 - Explicit payload (XML) - recommended method
{%- set file = __long_id | get_resume_filename -%}
{%- set extension = (file or '').split('.')[-1].upper() -%}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="name"
{{first_name}} {{last_name}}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="stage"
{{'lead-new' if __journey_candidate_status == 'Capture: Capture Incomplete' else 'applicant-new'}}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="phones[0][value]"
{{phone_number}}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="emails[]"
{{email}}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="tags[]"
Paradox
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="sources[]"
Paradox
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="origin"
applied
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="resumeFile"; filename="{{__long_id|get_resume_filename}}"
Content-Type: {{ extension | mapvalue('doc-content-type', 'plain/text') }}
{{__long_id|get_binary_resume_content}}
--WebKitFormDataBoundary492
{% if __journey_candidate_status == 'Disposition: Disposition' -%}
Content-Disposition: form-data; name="archived[reason]"
89c1e193-8329-418b-9ce4-ada6d45daf1b
--WebKitFormDataBoundary492
{%- endif -%}
Content-Disposition: form-data; name="postings[]"
{{__job_req_id}}
--WebKitFormDataBoundary492--Option 2 - Set Payload with Jinja (JSON)
This method may not work if you need to include a resume file.
{%- set payload = {
"name": first_name + " " + last_name,
"stage": 'lead-new' if __journey_candidate_status == 'Capture: Capture Incomplete' else 'applicant-new',
"phones[0][value]": phone_number,
"emails[]": email,
"tags[]": "Paradox",
"sources[]": "Paradox",
"origin": "applied",
"postings[]": __job_req_id
}
-%}
{%- if __journey_candidate_status == 'Disposition: Disposition' -%}
payload["archived[reason]"] = "89c1e193-8329-418b-9ce4-ada6d45daf1b"
{%- endif -%}
{%- for key, value in payload.items() -%}
--WebKitFormDataBoundary492
Content-Disposition: form-data; name="{{key}}"
{{value}}
{% endfor -%}
--WebKitFormDataBoundary492--
Additional examples
In case there is an error response, additional formatting may be required as these issues may occur on some servers (Windows Style) that accept only “\r\n” as a new line instead of “\n” (POSIX Style).
In Integration Center:
Headers:
- Key: Content-Type
-
Value: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
{%- set file = __long_id | get_resume_filename -%}
{%- set extension = (file or '').split('.')[-1].upper() -%}
{%- set data = __long_id|get_base64_resume_content -%}
{%- set br = "\r\n"|safe -%}
------WebKitFormBoundary7MA4YWxkTrZu0gW{{-br-}}
Content-Disposition: form-data; name="file"; filename="{{__long_id|get_resume_filename}}"{{-br-}}
{{-br-}}
{{__long_id | get_binary_resume_content}}{{-br-}}
------WebKitFormBoundary7MA4YWxkTrZu0gW--The following is the request set in POSTMAN:
curl --location 'https://api.smartrecruiters.com/candidates/9fa273cb-bb77-4bd0-8563-5228e9f2c12e/jobs/6ff24bb6-e2b8-4c49-b2af-ea60dd0cb27f/attachments' \
--header 'accept: application/json' \
--header 'x-smarttoken: ******************' \
--header 'Cookie: AWSALB=Sx/8hHQlha8ZFbDP10QcPvYN6sAY9VihJxgv16/jtxctV4PkU3yXSC5i24N/6qrRo+O6WRKC4I+AGiwk/Gkr82/0w6rn/lpxFx93bGoiDa9Petu0fCNTRJ07w6Vx; AWSALBCORS=Sx/8hHQlha8ZFbDP10QcPvYN6sAY9VihJxgv16/jtxctV4PkU3yXSC5i24N/6qrRo+O6WRKC4I+AGiwk/Gkr82/0w6rn/lpxFx93bGoiDa9Petu0fCNTRJ07w6Vx' \
--form 'attachmentType="RESUME"' \
--form 'file=@"/C:/Users/YOUR_USER_NAME/Desktop/PDX/Resume_test_file.pdf"'