cancel
Showing results for 
Search instead for 
Did you mean: 

Retrive files from ABAP Backend into a Swift APP

danielesteban1
Explorer
0 Kudos

Hello,

I use an ABAP backend based on an OData service with the "GetStream" method overridden to respond with PDF files generated in the backend.
That part works well! If I call the URL from SAP in the Gateway client:

sap/opu/odata/sap/MY_ODATA_SRV/myEntitySet(Key1='',Key2='')/$value

It shows the PDF file! 😄

The problem I am facing is that I don't know how to retrieve that file in Swift using the iOS SDK.
(I'm building an ONLINE app)

I attempted with this code, but it didn't work:

        let oItem = MyODataSrvFmwk.MyEntity()
        oItem.key1= "123"
        oItem.key2= "123"
        Task{
            do{
                let media = try await myOData.dataService!.downloadMedia(entity: oItem)
                print(media)
            }
            catch{
                print(error)
            }
        }

This code always ends up in an error.

Could you please help me with this?

On the other hand, I searched the documentation and found nothing.

I am using the documentation from:

https://help.sap.com/docs/btp-sdk-ios/sap-btp-sdk-for-ios/utilizing-odata-api?locale=en-US

Is there another one that is more complete?

View Entire Topic
evanireland
Advisor
Advisor
0 Kudos

If loadfing the entity first helps, that can be achieved with:

try await myOData.dataService!.loadEntity(oItem)

but perhaps if you share the actual error that you received, that would help, since just setting the key values in a new entity should work if the backend supports uses canonical URLs for accessing the media stream (as it appears to from the URL you provided).