Yes, the sa variable contains the byte version of the file in ServiceNow. I tried to print the value of it which returned “[B@7e8de4”.
One more thing which I wanted to know is, while uploading the file to Box, in which format does Box accept the attachment? (Eg: Binary format, Base64 etc.)
If it helps, here is a small Python function I wrote years ago to use the BoxSDK to upload to a folder. Folder ID is required, as is a live connection to Box. I played around with the requests library in Python for a while before coming back to the BoxSDK:
defupload2Box(boxConn, boxTargetFolderId, sourceFilePath, sourceFilename):'''upload a file to a folder in Box'''try:
boxConn.folder(boxTargetFolderId).upload(sourceFilePath, sourceFilename)
returnTrueexcept:
returnFalse
Could you provide me the HTTP equivalent of this cURL request? Because here I can see only the Filename which is being passed in the file attribute. Doesn’t give much insight as to how the file “metadata/payload” is being encoded.
Also a quick info about this function “sn_ws.RESTMessageV2()” it is basically a function which calls the REST message which is already configured in ServiceNow. It is used to configure the URL, endpoints, payload etc. for the request which we are making.
In addition to this, I have tried giving both binary and base64 encoded file contents, but received the same error for both. Do I need to mention the encoding type in which the file is encoded in the request which I am sending?
Yup even I tried with the Box SDK in python which makes the whole process very simple.
The problem being that in ServiceNow we don’t have SDKs which we can use to make this possible. So need to configure everything manually. And SDKs just encapsulate everything about the payload which is being sent.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.