submit / upload file via JSON API Call
after login and getting session id i will upload an 1,5 MB file with the following code:
def sendSmallFile(file_content_as_base64, file_name):
print("try to send small file to sandbox")
print(f"start of base64 content: {file_content_as_base64[:100]}")
print(f"got filename: {file_name}")
submitURL = "https://fortisand-api.our-domain.de/jsonrpc/"
submit_json_data = {
"method": "set",
"params": [
{
"file": file_content_as_base64,
"filename": file_name,
"skip_steps": "2",
"url": "/submit-file",
"type": "file",
"vrecord": "0",
"enable_ai": "",
"forcedvm": 1,
"browser": 0
}
],
"session": session_id,
"id": 11,
"ver": "4.4.0"
}
response = requests.post(submitURL, json=submit_json_data)
sid = getValueFromResponse(response.json(), "sid")
print(f"sid: {sid}")
the base64 content is encoded:
file_content = file.read()
file_content_base64 = base64.b64encode(file_content)
in the debugger it looks ok:

but python get me an TypeError: Object of type bytes is not JSON serializable (in the code line to get the response from the request).
Any ideas?
thanks a lot!
