1

Using Mayan EDMS, I am unable to add a document to a cabinet.

I am using PHP to send, create and upload a document, which works well. Thereafter, trying to add the document to the cabinet results in the following error

{"detail":"Not found."}

I am at a loss on how to proceed as the API documentation is not clear about the request body and fails on the execute in the swagger documentation.

   // Add document to cabinet
    $cabinet = $params['cabinet'];
    $data = array (
        'document' => [$document_id],   // values must be a list []
    );

    $post_data = json_encode($data);
    $request_url = 'http://example.com/api/v4/cabinets/' . $cabinet . '/documents/add/';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request_url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);

    $headers = [];
    $headers[] = 'Accept: application/json';
    $headers[] = 'Content-Type: application/json';
    $headers[] = 'Content-Length: ' . strlen($post_data);
    $headers[] = 'Authorization: Basic YWRtaW46QndLcFNaQnJURDI3MzN5';

    $result = curl_exec($ch);
    // $result returns : {"detail":"Not found."}
    curl_close($ch);
crafter
  • 6,246
  • 1
  • 34
  • 46

0 Answers0