Symptom
- An API to allow import of documents to be attached to an Onboarding panel. Each document will be g-zipped and passed in a base64 encoded format in API.
- All Documents supported in Recruiting can be imported with exception of HTML Documents.
- Customers can pass the Recruiting documents to be used in Onboarding through this API.
Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.
Environment
SAP SuccessFactors Onboarding 1.0
Resolution
Please follow below 12 steps:
- Panel: Create a upload option and give form code.
-
Create a test candidate:
a) and get the hrdata id of candidate(Test Gopi- b4da3efe-9f23-47a1-87c9-384de3904c17)
b) Do not upload file.
c) Documents can be uploaded through API until candidates completed onboarding process. -
Test: PDF File is going to be uploaded through odata API for candidate (Test Gopi).
-
But first, you need to convert a file to gz format before performing uploading a file:
a) Converting Test.pdf file to gz format. Please find below screenshots for reference.
b) Gz file is ready now: (Test.pdf.gz) -
Upload a gz file using encoder and as a output you will receive a text file format.
Please find below screenshots how to use base64 encoder:
a) Search base64 in google.
b) Cclick on encode(at top), upload a file (Test.pdf.gz) and click on encode at bottom(>Encode>).
c) Output will be Test.pdf.Txt(With encoded content) -
Create a odata in service login in superadmin:
-
a) We need to encode the above odataservice login using base 64 encode and decoder:
b) Cick on 'Encode' and provide below user details, encode it. (>Encode<)
{"UserName":"GopiTrain","Password":"GopiTrain"}
c) Output value will retrive: eyJVc2VyTmFtZSI6IkdvcGlUcmFpbiIsIlBhc3N3b3JkIjoiR29waVRyYWluIn0= -
Open Postman Tool(Download it from google).
- Posting the file: My account in dc4 sales demo so url is maintained as below.
a) Token generation using GET Method:
- Get method: https://sales-onboarding4.successfactors.com/ONBSALES/odata/v2/ODataAuthentication
- In headers provide key as : Authorization
Value as : Basic eyJVc2VyTmFtZSI6IkdvcGlUcmFpbiIsIlBhc3N3b3JkIjoiR29waVRyYWluIn0= (Above encoded value is which we received from pt 7©.)
- Click on send and token will be generated for authentication:
- Token:cf0f7e07-04bf-420a-bd49-9e12063a1126
b) Posting a file using POST method:
- Add the url: (Sample url) https://sales-onboarding4.successfactors.com/ONBSALES/odata/v2/OnboardeeAttachment
- Click on headers and add below:
- Authorization as key:
Value is token :cf0f7e07-04bf-420a-bd49-9e12063a1126 which we fetched in step 9(a)
-Please find below screenshots for reference:
- Click on body -choose raw and click on json
- In body enter below details: Please make sure data is maintained in below format:
[
{
"HrDataId" : " b4da3efe-9f23-47a1-87c9-384de3904c17",
"AttachmentName" : "TestDoc.pdf",
"FormCode" : "Test",
"AttachmentContent": “<base-64 encoded g-zipped file content>”
}
]
- PS: <base-64 encoded g-zipped file content>”-enocded format which we obtained in pt 5© and also in request 4 braces[{}] are mandatory as stated above.
c) Click on send and you will receive below response:[
{
"HrDataId": " b4da3efe-9f23-47a1-87c9-384de3904c17",
"AttachmentId": "7ba925e6-0117-47de-9bc3-fea4c3bbaffb",
"AttachmentName": "TestDoc.pdf",
"StatusCode": "200",
"StatusMessage": "Document successfully Uploaded"
}
]
d) Now login and check , for the candidate document will be successfully uploaded. - Downloading a uploaded file using GET Method:
Fetching all records of candidate using below method:
a) Enter below url: (sample) https://salesonboarding4.successfactors.com/ONBSALES/odata/v2/OnboardeeAttachment?$filter=HrDataId eq guid'b4da3efe-9f23-47a1-87c9-384de3904c17'
b) In Header ,enter key as Authorization and value as token .Please find below screenshot:
c) Click 'Send' and you will receive below response:
{
"odata.metadata": "http://localhost/xp/odata/v3/$metadata#OnboardeeAttachment",
"value": [
{
"HrDataId": " b4da3efe-9f23-47a1-87c9-384de3904c17",
"AttachmentId": "7ba925e6-0117-47de-9bc3-fea4c3bbaffb",
"AttachmentName": "documentTwo.txt",
"FormCode": "Blue",
"AttachmentContent": "<base-64 encoded g-zip content”,
"AttachmentDetails": [
{
"Key": "ShowInWorkQueue",
"Value": "True"
},
{
"Key": "MimeType",
"Value": "text/plain"
}
]
}
d) You will receive the output in decoded format. - Decoding a file:
Now open motobit in google to decode file:
- Converting decoded text(received as response in point 10©).
- Please refer below screenshot: - Converting gz to normal file format:
Gzfile(test.pdf.gz) will be the output and extract it to normal pdf .please find below screenshot: - test.pdf will be retrieved.
PS: Using guide we downloaded all documents for a candidate. We can download a single document using attachment ID or form code by below api calls.
- GET ATTACHMENT BY ATTACHMENT ID
REQUEST:
-URI: https://<Hostname>/<PartnerName>/odata/v2/OnboardeeAttachment(‘<attachment-id>’)
-METHOD: GET
-HEADERS: Authorization: <Token obtained from oData Authentication API>
-PAYLOAD: None
RESPONSE:
{
"odata.metadata": "http://localhost/xp/odata/v3/$metadata#OnboardeeAttachment",
"value": [
{
"HrDataId": "90a72911-9444-4ad3-9698-035f6a528a16",
"AttachmentId": "15bc306b-4eaa-4019-b351-6f7eb74bbf3a",
"AttachmentName": "documentTwo.xls",
"FormCode": "Blue",
"AttachmentContent": “<BASE-64 ENCODED G-ZIP CONTENT”>
"AttachmentDetails": [
{
"Key": "ShowInWorkQueue",
"Value": "True"
},
-
GET ATTACHMENTS FOR ON ONBOARDEE AND FILTER BY FORM CODE:
REQUEST:
-URI: https://<Hostname>/<PartnerName>/odata/v2/OnboardeeAttachment?$filter=HrDataId eq guid'90a72911-9444-4ad3-9698-035f6a528a16' and FormCode eq 'Blue'
-METHOD: GET
-HEADERS: Authorization: <Token obtained from oData Authentication API>
RESPONSE: Same as above.
Keywords
API, File Upload, Onboarding, ODATA API, Documents, Onboarding Panels, ONB 1.0, OBD , KBA , LOD-SF-OBD-API , Webservices & API's , How To