Skip to Content
Author's profile photo imran shaik

How to Upsert the Attachments into Successfactors Using SAP CPI

This blog describes how to upsert the attachments into Successfactors using SAP Cloud Platform Integration. I am using Job Application OData API to achieve this.

For any Attachment to upsert into Successfactors OData API, we should have to do this through Attachment OData API. Attachment is a generic API to upsert any attachment in Successfactors.

In this blog i am going to explain how to upsert the PDF file into JobApplication API. In my JobApplication API, I have a custom field whose data type is Attachment and having the navigation to Attachment API from that field. If you select the Sub Level-1, you can see the attachment fields. Any how, i have not used the Succssfacors adapter to upsert. I am just showing this screenshot for API navigation and field structure.

 

 

Once you select the JobApplication API, the business key field will be automatically ticked the check box and it appears in the upsertable fields list. But coming to the Attachment API, Attachment ID is the business key but we should not upsert any data into this field. In Attachment API, we have to select the fileContent, fileName, module fields. These 3 are the required fields in this API.The DataType for fileContent field is Base64. For module field you can hardcode to RECRUITING.

Integration flow design:

 

In the above screenshot, I get the PDF File content from HTTP Adapter and after that i am using the Encoder shape to do the Base 64 format of the PDF Content. After that i am creating one header as Content-Type as “application/json”. In Property, i have created one property as PDF and given the value to that property as the Base 64 Encoded data. After that i have created the body, which will accepts by the JobApplication API.

Content Modifier Screenshot:

Header:

 

Property:

 

Body:

Sample Json Data to Upsert:

{
“__metadata”:{
“uri”: “JobApplication(applicationId=’1234′)”
},
“applicationId”: “1234”,
“cust_ResultField”:{
“fileContent”:”SGVsbG8gV29ybGQh”,
“module”:”RECRUITING”,
“fileName”:”Result.pdf”
}
}

After that i am logging the payload data in the groovy script. After that, i am using the HTTP adapter to upsert the data into successfactors using POST operation and followed by the response catching using groovy script.

Best Regards,

Imran

Assigned Tags

      22 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Mohammed Ferozkhan
      Mohammed Ferozkhan

      Hi Imran,

      Thanks for great information.

      Regards,

      Ferozkhan

      Author's profile photo Harsh Bhatt
      Harsh Bhatt

      Hi Imran

       

      Thanks for sharing this blog. I have a question.

       

      While upserting using HTTP adapter, it is returning status 500. I analyzed everything but everything looks good with json payload and HTTP adapter.

      Could you please suggest?

      Author's profile photo Ravinder Boda
      Ravinder Boda

      Hi Imran,

      I am also having same requirement, sending Base64Encode from ERP to SF via HCI Middleware (Source and target both XML).

      We have DecodedBase64 file in HCI but while trying to POST the data to Custom Portlet, we are getting Issues. Can we send PDF content into attachment field. Please find the screen shot of HCI_Log. and also find the complete iflow of Payslip. Kindly guide us on this Process.

      Regards,

      Rawinder

       

       

      Author's profile photo imran shaik
      imran shaik
      Blog Post Author

      Hi Rawinder,

      Yes, we can send PDF content to attachment field. But it accepts the data in encoded format only. Use the Encoder shape to encode the PDF Content and set that in one property, like my screenshot above. After that take the content modifier and in it's body, place SF Formatted data(See My last screenshot). Also, use Request-Reply instead of End message. By using this you can see the upsert response from SF System. I also recommend to use HTTP Adapter instead of Successfactors. Try that and let me know if you face any issues.

      Regards,

      Imran

      Author's profile photo Ravinder Boda
      Ravinder Boda

      Hi Imran,

      I am sending Encoded Message and want to Decode in HCI but however i am failing to send the Decoded Message to SF. I have followed your steps but failing to Upsert the Decoded Data into SF.

      1. Have few doubts:- Can we convert Encoded data to Decoded data in HCI and Upsert into SF?

      2. I am using Https as recommended but I am getting the data in XML(from source) format so should we send XML target side or  we can send Json as well?

       

      Regards,

      Rawinder

       

       

      Author's profile photo imran shaik
      imran shaik
      Blog Post Author

      Hi Rawinder,

      1. Attachments accepted in Encoded format only. You no need to decode the attachment in CPI. You can see the decoded- attachment directly in SF
      2. Yes, You can send XML as well using Https.
      3. First you make the trails with any rest tool like Postman/Boomerang to upsert the data into SF. Once, it is success, do with CPI.

      Regards,

      Imran

      Author's profile photo Wajahat Imam
      Wajahat Imam

      HI Imran,

      I am working on attachment, all looks good, but when I post as json or xml SFSF give me below error.

      Inline edit for 'cust_FilesNav' is not supported. with the index 0

      below is my payload

      {
      "__metadata":{
      "uri": "cust_FileDemo"
      },
      "externalCode": "1234",
      "effectiveStartDate":"/Date(1556568000)/",
      "cust_FilesNav":{
      "fileContent":"JVBERi0xLjQKJe",
      "module":"EC",
      "fileName":"Result.pdf"
      }
      }

       

      Please let me know if I am doing anything wrong.

       

      Thank you in advance.

      Wajahat Imam

      Author's profile photo imran shaik
      imran shaik
      Blog Post Author

      Hello Imam,

      You are missing the Business key in the structure. You have to maintain the business key corresponding to the API you are using(cust_FileDemo). Check the below corrected payload.

       

      {
      “__metadata”:{
      “uri”: “cust_FileDemo(“externalCode”: “1234”)"
      },
      “externalCode”: “1234”,
      “effectiveStartDate”:”/Date(1556568000)/”,
      “cust_FilesNav”:{
      “fileContent”:”JVBERi0xLjQKJe”,
      “module”:”EC”,
      “fileName”:”Result.pdf”
      }
      }

       

      Regards,

      Imran

      Author's profile photo Ananda Paul
      Ananda Paul

      Hi Imran,

      I am also getting the same error. I have attached the sample request that I posted and I am getting error response as Inline edit for 'cust_attachmentNav' is not supported

      usersSysId is nothing but the externalCode.

      Flow details:

      Adapter - SuccessFactors

       

       

       

      <?xml version="1.0" encoding="UTF-8"?><cust_Payslip3>
        <cust_Payslip3>
          <PeriodStartDate>2019-02-02T10:00:00</PeriodStartDate>
          <cust_PeriodEndDate>2019-02-02T10:00:00</cust_PeriodEndDate>
          <mdfSystemTransactionSequence>123</mdfSystemTransactionSequence>
          <usersSysId>222333</usersSysId>
          <cust_Gross>55000</cust_Gross>
          <cust_Deductions>2000</cust_Deductions>
          <cust_attachmentNav>
            <Attachment>
              <attachmentId>12345432</attachmentId>
              <fileContent>JVBERi0xLjQKMSAwIG9iago8PC9UeXBlIC9YT2JqZWN0Ci9TdWJ0eXBlIC9JbWFnZQovTmFtZSAvSkkxYQovV2lkdGggMTY1MwovSGVpZ2h0IDIzMzgKL0JpdHNQZXJDb21wb25lbnQgOAovQ29sb3JT==</fileContent>
              <fileName>one.pdf</fileName>
              <module>GENERAL_OBJECT</module>
              <userId>adminHCI</userId>
              <viewable>true</viewable>
              <deletable>false</deletable>
            </Attachment>
          </cust_attachmentNav>
        </cust_Payslip3>
      </cust_Payslip3>
      
      Author's profile photo Silvia Grabmann
      Silvia Grabmann

      hi,

      please find the following sap note if you are using a custom mdf

      https://launchpad.support.sap.com/#/notes/0002599554

      thanks silvia

      Author's profile photo Ananda Paul
      Ananda Paul

      Hi Silvia,

      Thanks for the link.

      I followed the link exactly like inserting the Attachment table and then inserting the MDF with the attacmentID that was returned in the previous insert. I have attached the request payload to insert cust MDF table with the attacmentID. I am still getting the error as Inline editing for cust_MDF is not supported. wiht the index 0

      Can you please point me where I am wrong?

      Author's profile photo Silvia Grabmann
      Silvia Grabmann

      Having the same issue if I am trying to add it per xml payload. Per json it is working fine. Seams an incident is necessary.

       

      thx silvia

      Author's profile photo Ananda Paul
      Ananda Paul

      Hi Silvia,

      Meanwhile, I tried posting it in JSON format. But, SuccessFactors adapter does not like the json format. It was giving me XML parser exception. Its looking for xml tag, but the body starts with { as its a json. I cannot submit it though http adpater.

      Can you please guide me on how to use SF adapter to post the json format data? OR post it via http adapter?

      JSON Req. message:

      {
      "__metadata": {
      "uri": "Attachment"
      },
      "userId": "adminhci11",
      "fileName": "json-payslip.pdf",
      "module": "GENERIC_OBJECT",
      "description": "payslip file",
      "fileContent": "adsf234asdf2903irojfj3dovTmFtZSAvSkkxYQovV2lkdGggMTY1MwovSGVpZ",
      "viewable": true,
      "deletable": false
      }

      Rgs,

      Anand…

      Author's profile photo imran shaik
      imran shaik
      Blog Post Author

      Hi Ananda,

      Please use http adapter with Json format. Correct the below 2 lines in your Json Payload and try to upsert.

      {

      “__metadata”:{
      “uri”: “Attachment(“userId”: “adminhci11”)”

      }

      Regards,

      Imran

      Author's profile photo Ananda Paul
      Ananda Paul

      Hi Imran,

       

      I just now saw your message. I implemented this via XML format.

      Thanks for your blog and help

      Author's profile photo Elton Chen
      Elton Chen

      Hi Imran,

      Thanks for great information. I am an ABAP developer and want to learn SF API.

      I want to know how can I get the Json code from SF API.

      In SF API center, I only can see the structure for API, but no Json code.

      Could you tell me how to go through Content Modifier .

       

      Sample Json Data to Upsert:

      {
      “__metadata”:{
      “uri”: “JobApplication(applicationId=’1234′)”
      },
      “applicationId”: “1234”,
      “cust_ResultField”:{
      “fileContent”:”SGVsbG8gV29ybGQh”,
      “module”:”RECRUITING”,
      “fileName”:”Result.pdf”
      }

      Author's profile photo praveen kalwa
      praveen kalwa

      Hi Imran - I have the similar requirement but my middle ware is SAP PI, can we use the same using SAP PI . If you have any step by step flow using SAP PI . Please reply in the thread.

       

      Regards

      Praveen K

      Author's profile photo Vivian Smid
      Vivian Smid

      Hello guys!

       

      When the upsert occurs in the same user of the SuccessFactors that is configured in the CPI, the integration completes, 
      but when it is done for another user of the SuccessFactors the following error occurs:
      There is no permission to access the attached file 0010004338462019.pdf. 
      The attachment in the cust_attachment field does not belong to the user adminEC.
      
      
      Can anybody help me?

       

      Author's profile photo jaideep shetty
      jaideep shetty

      Hi Vivian,

       

      Were you able to find the cause or resolve this ?

       

      Thanks

       

      Author's profile photo Vivian Smid
      Vivian Smid
      Hi Jaideep,
      
      Yes, I was able to solve this problem!
      I just had to pass the user configured in the "Security Material" of Success 
      
      to the API "Attachment", in the userId field.
      I was passing the user of the person who would access the Success (001000433
      Author's profile photo jaideep shetty
      jaideep shetty

      Hi Vivian,

       

      Thank you for reply.

       

      May I know what did you mean when you said Security Material?

      "pass the user configured in the Security Material"
      
      
      Thank you,
      Jaideep Shetty
      Author's profile photo Priffy Consultant
      Priffy Consultant

      ​I have a problem in accessing upsert functionality of SuccessFactors from CPI. I am using Succesfactors odata v2 adapter in CPI but I am unable to find the Upsert Enitity .

       

       

      I cannot find the upsert Entity in the SuccessFactors OData v2 in CPI. But I am able to access the same using Postman. Other odata functionalities are accessible from CPI using Oauth2 saml bearer token. Upsert functionality belongs to function-import  operation of SuccessFactors adapter. Is it implemented in SuccessFactors adapter?

      Cannot%20find%20the%20upsert%20entity%20in%20SF%20adapter

      Cannot find the upsert entity in SF adapter

      Postman%20Client

      Postman Client

      In the screenshot, I am able to access the same upsert odata in postman using oauth token. I am unable to find the same in CPI. Kindly provide the solution for this issue.

      Thanks in advance.