on 03-20-2017 6:59 AM
Hi,
I am developing a ui5 aplication fro use on HCP Portal which has C4C as a data source.So right now when i am using UploadCollection control on ui5 to upload documents against a Service Request in C4C using standard odata service c4codata i am getting a "415 error Unsupported Media Type" Error.
onChange: function(oEvent) {
var c4c1 = "/C4COdataAccount/sap/c4c/odata/v1/c4codata/";
var oModel = new sap.ui.model.odata.ODataModel(c4c1, true);
oModel.refreshSecurityToken();
oModel.setHeaders({
"content-type": "application/json;charset=utf-8"
});
var oHeaders = oModel.oHeaders;
var sToken = oHeaders['x-csrf-token'];
var oUploadCollection = oEvent.getSource();
var oCustomerHeaderToken = new sap.m.UploadCollectionParameter({
name: "x-csrf-token",
value: sToken
});
oUploadCollection.addHeaderParameter(oCustomerHeaderToken);
},
onStartUpload: function(oEvent) {
var oUploadCollection = sap.ui.getCore().byId("UploadCollection");
for (var i = 0; i < oUploadCollection._aFileUploadersForPendingUpload.length; i++) {
oUploadCollection._aFileUploadersForPendingUpload[i].setUploadUrl(sUploadUrl);
}
oUploadCollection.upload();
},
onBeforeUploadStarts: function(oEvent) {
// Header Slug
var sFileName = oEvent.getParameter("fileName");
sFileName = encodeURIComponent(sFileName);
var oCustomerHeaderSlug = new sap.m.UploadCollectionParameter({
name: "Name",
value: sFileName
});
oEvent.getParameters().addHeaderParameter(oCustomerHeaderSlug);
var oUploadCollection = oEvent.getSource();
sap.ui.getCore().byId("UploadCollection").setUploadUrl("/C4COdataAccount/sap/c4c/odata/v1/c4codata/ServiceRequestCollection('" +
objid + "')/ServiceRequestAttachmentFolder");
sUploadUrl = "";
sUploadUrl = "/C4COdataAccount/sap/c4c/odata/v1/c4codata/ServiceRequestCollection('" + objid + "')/ServiceRequestAttachmentFolder";
},
onUploadComplete: function(oEvent) {
var oMsgStrip = new sap.m.MessageStrip({
text: "Success",
showCloseButton: true,
showIcon: true,
type: "Success"
});
},
Can i get some suggestions how to resolve this issue.I have attached the pics for C4C odata service for attachment and the header responce in console.
Can you change the header data, please?
oModel.setHeaders({"content-type": "text/plain;charset=utf-8"});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any help would be greatly appreciated.
Regards,
Kaustubh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.