on 2020 Dec 21 7:46 AM
Hello Experts,
I have developed a Fiori mobile app which is based on SAP Hybrid Application Toolkit framework. I have a requirement in application to attach the file from my mobile device and save it in backend ECC system. I am using UploadCollection control for the same.
I am able to upload the attachments successfully if am running the same in Android Hybrid mobile app or directly in browser. However, same code is not working in IOS Hybrid app. I am getting success message as well i.e. File uploaded successfully but same attachment is not getting saved in backend. I checked the traces in backend system using Tcode /iwfnd/traces but call is not reaching till backend system and i do not get any traces there.
Please find below the code snippets:
View:
<UploadCollection id="UploadCollection" multiple="true" sameFilenameAllowed="true" instantUpload="true" fileDeleted="onFileDeleted"
uploadComplete="onUploadComplete" beforeUploadStarts="onBeforeUploadStarts" change="onChange" mode="Delete"/
Controller methods:
I am suspecting that it might be an issue with CSRF token. As we know, we have to send the CSRF token along with the post call to send the attachment to the backend system.
Now, to get the CSRF token first, i have tried multiple ways :
1. Get CSRF Token using OData Model getSecurityToken()
var oDataModel = this.getView().getModel("Offline");
var sST = oDataModel.getSecurityToken();
This is giving me value as undefined in both Android and IOS hybrid apps. However, i am getting CSRF value here in case i am running it directly from browser. I am passing "X-CSRF-Token" with value "Fetch" as well in request header.
2. Get CSRF Token using OData Model refreshSecurityToken()
Again, CSRF token is missing in response header in both Android and IOS hybrid apps but working fine in browser. I am passing "X-CSRF-Token" with value "Fetch" as well in request header.
3. Get CSRF Token using AJAX call:
I have used above code code to get the CSRF token. This piece of code worked perfectly fine in Android Hybrid app and attachment was saved in the backend successfully. But, i am assuming this code didn't work well with IOS hybrid app.
Kindly help me with your expertise in resolving this issue.
P.S. I am unable to debug IOS device app on windows laptop. Kindly suggest if you have any tricks to debug IOS device on window as well.
Regards,
Happy Chhillar
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.