Skip to Content

multiple file upload in service tickets using oData

Nov 09, 2016 at 10:08 PM


avatar image
Former Member

I am currently writing an SAPUI5 app that will be used to create service tickets using oData onto C4C.

The user has a form to create the service tickets. This form also has an option to upload multiple files and also multiple items with products.

For creating the items I am using oData batch processing

I am able to upload a single file using something like below:

However, I am having a difficult time to come up with the approach on how I can handle the multiple files. In case of single file, the actual oData call is currently happening on fileReader.onload

How can I accomplish for using multiple files ??

Any suggestions are highly appreciated.

		uploadPictures: function(result) {
			if (this.picturesFileToUpload) {
				var fileReader = new FileReader();
				fileReader.onload = function(e) {
					this.uploadFile(e, result);

		uploadFile: function(e, result) {
			var model = this.getModel(),
				url = result.getElementsByTagName("id")[0].innerHTML + "/ServiceRequestAttachmentFolder",
				token = model.getSecurityToken();

			var data = {
				Binary: window.btoa(

				url: url,
				method: "POST",
				contentType: "application/json",
				headers: {
					"X-CSRF-TOKEN": token
				data: JSON.stringify(data),
				success: this.finishCreateTicket.bind(this),
				error: function(jqXHR) {
					var error = jqXHR.responseXML.getElementsByTagName("message")[0].innerHTML;
					MessageBox.error("The service request was created successfully, but the attachment could not be uploaded: " + error);
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Manjinder Singh Nov 10, 2016 at 08:40 AM

Hi Rozal,

i have not the answer for your question. However, i am curious to know how to you archieve data upload via OData service? Could you provides some information how do you archieve it on the backend side.




10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 10, 2016 at 01:41 PM

The C4C oData service has a collection called ServiceRequestAttachmentFolder that lets you to add attachemnts onto the service tickets. The sample for it is provided in the initial application that sap provides on github

10 |10000 characters needed characters left characters exceeded