Search code examples
javascripts4sdk

How to get the content of an attachment with the JS SDK for S4/HANA?


So I am currently in the process of learning the new Javascript Cloud SDK. Of course there is also a package for attachments and document info records but I am still facing some problems.

So mainly I just want to get an attachment which is attached to a document info record and safe it to my local file system. I am working with the JS Cloud SDK so I am working with a Node application.

When working with the API directly (testing via Postman) I can get the media_src of the attachment simply by adding '$value' to the request path. When I try to access this URL outside of Postman with a simple Node https.get request I get a SAML 2.0 Error (SAML2 Service not accessible). I guess that is because I cannot access those URLs via browser and therefore I should use the SDK for that.

So the final problem I am facing is that I cannot find anything about getting the file itself in the JSDoc of the SDK.

Same goes also for creating an attachment. Should I use the 'builder()' method for that and pass a JSON object or how does a POST or PUT request work with that SDK? I cannot find any blogs etc. because they are only doing simple 'Hello World' programms or GET some data.


Solution

  • thanks for reaching out to us! Currently, we do not support OData media streams in the JS SDK's VDM yet. If this functionality is critical for you, you can consider using the Java version of the SDK. Alternatively, you can open an issue here.

    Regarding the SAML error I cannot comment, since I don't how your Postman is configured or how your system is setup.