cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading an image through SAP Mobile Platform from device.

Former Member
0 Kudos

Hi,

I am trying to upload an image of .jpg format from a mobile app to my database. We have used phone gap api to access the image from phone gallery and we are using FileTransfer() method to upload the image.

This works fine when we are directly connecting to NW Gateway and we are able to see the image uploaded on gateway but when we try the same thing with SMP as middleware between Device and Gateway we get 401 - UNAUTHORIZED error.


Can anyone provide some inputs on this and if any documents to be referred.


The code I have used is shown below is for Uploading :

Thanks in Advance Friends....

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If you are using the REST API for onboarding and connecting through SMP you need to add the Application Connection ID as well to be authorized.

X-SUP-APPCID

If the FileTransfer of Phonegap still fails (i.e it might not have the cookies you require) you can send the data as a base 64 encoded string instead.

BR

Njål

Former Member
0 Kudos

Hi,

Thanks for responding.

I tried using the X-SUP-APPCID, but this time in device logs it initially shows as uploading and once the complete data is sent I get the response code as 401 and in response headers I get 401 Unauthorized and it goes into my error function of File Transfer.

The headers which i am passing :

uploadCreate has my APPCID.

var headers = {

  "X-Requested-With" : "XMLHttpRequest",

  "Content-Type" : "application/atom+xml",

  "DataServiceVersion" : "2.0",

  "Accept" : "application/atom+xml,application/xml,application/atomsvc+xml",

  "X-CSRF-Token" : "Fetch",

  "X-SUP-DOMAIN" : "LntOdDomain",

  "X-SUP-APPCID" : uploadCreate

  };

params.username = uid123;

params.password = pwd123;

params.headers = headers;

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Samanth,

correct me if i am wrong, since you are using phoneGap API that means your development is for hybrid app and SAP as backend.

Is this MBO based app or OData based app?

Rgrds,

Jitendra

Former Member
0 Kudos

Hi Jitendra,

Yes its an hybrid app built using SAPUI5 platform based on OData.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

can you look at

Former Member
0 Kudos

It wasn't of much help Jitendra.