cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a REST "PUT" call to a dynamic url and pass Binary file content in body in SAP MDK

geetbijlani
Participant
0 Kudos
301

Dear All,

I am working on MDK app in which I need to make a REST "PUT" call to a dynamic url generated in previous rest api calls and pass the Binary file content in body. I am not really sure how to approach this as I have a file path where the template word file is stored.

The dynamic url is a pre-signed url from Adobe Document Services where this file from my machine needs to be uploaded.

 

Best Regards,

Geet

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos
What MDK version and platform are you working with?
geetbijlani
Participant
0 Kudos
Hi Bill, I am developing this on BAS ->MDK 23.4+ (For use with MDK 23.4 or later clients)->for iOS platform
View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

First you will need the root of the REST service defined as a destination in Mobile Services with appropriate authentication.  Then you can use clietnAPI sendRequest method to create your PUT request specifying the URL as the path starting with the destination name and subpath as needed.

geetbijlani
Participant
0 Kudos

Hi @bill_froelich ,

I am kind of struggling to get this working:

1. Created a destination in mobile services.

 

geetbijlani_1-1718873555539.png

2. Created MDK service

geetbijlani_2-1718873655108.png

3. Used it using sendRequest:

geetbijlani_5-1718963696565.png

4. I always get a Forbidden -403

geetbijlani_6-1718964595168.png

However, the same credentials and code work for fetch( ) or via Postman and also via Build Process Automation/Build Apps.

I also tried doing it via an action and I get a 401- Unauthorized

geetbijlani_9-1718966068498.png

 

geetbijlani_7-1718965695610.png

 

 geetbijlani_8-1718965993738.png

Could you please point me in the right direction on how to use clientApi.sendRequest successfully as the fetch() works fine for web app but for mobile devices is does not work.

Best Regards,

Geet

 

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos
I would recommend turning on Mobile Network Trace in Mobile Services to confirm exactly what is being sent to the destination. I would also use a REST client (postman or similar) to send the same request through the Mobile Services destination you created to verify that it is correctly configured.