cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass the raw data as content for Attachment API in S/4 HANA Cloud

Babu_Lal_Limba
Product and Topic Expert
Product and Topic Expert

Customer has developed interfaces to pass the attachments from external systems to their existing ERP system. They were sending the content of the file (raw data) in the payload in this interface. Now they switch to S/4 HANA Cloud ERP and the same integration is required.

However, the attachment API in S/4 expects the content to be as a file and not the raw data for attachment purpose. Is there a way customer can still send the raw data (content of file) and the attachment API can accept it? Or there is another API to work out this problem?

Regards

Babu

JulianoRomanato
Product and Topic Expert
Product and Topic Expert

Hello babu.lallimba.

How are you? I have excluded the Tag "SAP S/4HANA Cloud for Research and Development" and included the Tag "SAP S/4HANA Cloud Extensibility" for this question, as API is an Object of Extensibility.

Regards.

Juliano Romanato.

robertfels
Participant

To pass the raw data as content for the attachment API in S/4 HANA Cloud, you can use the POST /sap/opu/odata/sap/API_DOCUMENT_SRV/API_DOCUMENT_SRV API. This API allows you to create an attachment in the S/4 HANA system by passing the raw data as the content in the request body.

Babu_Lal_Limba
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Robert Fels,

Thanks for the inputs. I tried that and passed the raw data into the request body. It worked and the attachment is added to the business object Billing Document. But when I open that attachment from the Billing Document the system cannot read that PDF and open it. Is there anything else I need to do?

Regards

Babu

Marissa
Advisor
Advisor
0 Kudos

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if you have further questions.

Accepted Solutions (1)

Accepted Solutions (1)

Enda
Product and Topic Expert
Product and Topic Expert

Hello Babu

The API https://api.sap.com/api/API_CV_ATTACHMENT_SRV/overview is the only API in S/4HANA Cloud

that im aware of that can upload attachments.

Have you tried using the API in Postman using the method outlined in the thread ?

https://answers.sap.com/questions/13728197/api-cv-attachment-srvattachmentcontentset-pdf-cont.html

in S/4HANA Cloud , the supported MIME types are listed at the link

https://help.sap.com/docs/SAP_S4HANA_CLOUD/7489fa08cede494cbdf08fa3651598af/cdd8e064b36f46fe87eb2b73...

Best Regards

Enda

Babu_Lal_Limba
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Enda,

Thanks for the reference blog and I checked it. However in my use case I don't have a file to select. I have the data representing the PDF file (I want to attach). I want to pass this data and get the file created in the business object as attachment.

Regards

Babu

Babu_Lal_Limba
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello enda.fennelly

I have a payload from external system that passes me the pdf file as a base64 string. I need to create an attachment of type pdf, out of this string in S/4 Billing Document object. I am using the S/4 Attachments API (as you have mentioned). I have passed header and body as shown below in the images.

The file is attached as pdf. But this pdf does not open and I get an error "Error in loading pdf". Looks like the system is not able to understand this base64 string. Do we need to convert this string into other format before passing to attachment body?

Message Header:

Message Body: I pass the base64 string as shown

Any help or hint would be highly appreciated. Thanks a lot in advance.

Regards

Babu

0 Kudos

Hi Babu

How did you manage to make the request work with a raw content in the body?

I encoded my PDF to base64 and it was successfully added to GOS, but I can't open the file.

Any help or hint would be highly appreciated. Thanks a lot in advance.

Regards

Abdoulaye

Jaman
Participant
0 Kudos

Hi Abdoulaye,

I am facing the same problem. Did you find solution for this?

Thanks,

Ahamed

Answers (0)