I'm trying to post file in Attachment. Aсcording to other topics: i need to send json with file encoded to base64. I found some php code, but it doesn't work, even php. When i remove field "file", response - 200, but there is no any file attached.
My python code also fail in this field.
Example php:
$postFields = json_encode(array(
'name' => 'tr.txt',
'publishDate' => date('Y-m-d'),
'type' => 'application/octet-stream',
'size' => 356297,
'file' => ',' . base64_encode(file_get_contents('F:\project\common \tr.txt')),
));
Response:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE
X-Powered-By: PHP/7.1.33
X-Status-Reason: Params 'field' and 'parentType' not passed along with 'file'.
Content-Length: 0
Connection: close
Content-Type: text/html;charset=UTF-8
But as the result, i must write it on python.
My python code also fail in this field.
Example php:
$postFields = json_encode(array(
'name' => 'tr.txt',
'publishDate' => date('Y-m-d'),
'type' => 'application/octet-stream',
'size' => 356297,
'file' => ',' . base64_encode(file_get_contents('F:\project\common \tr.txt')),
));
Response:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE
X-Powered-By: PHP/7.1.33
X-Status-Reason: Params 'field' and 'parentType' not passed along with 'file'.
Content-Length: 0
Connection: close
Content-Type: text/html;charset=UTF-8
But as the result, i must write it on python.
Comment