Create document with PHP

Hi,

I am writing the service to create a document on the content server (16.2) with PHP web application. I found the error {"error":"Could not process object, invalid action \u0027create\u0027"}.

Could you please advise me how to write the service to upload the document through custom web application?

Here is the code

$fields = [

'type ' => 144,

'parent_id' => $nodeid

'name' => $fileName,

'file' => $file

];

$headers = array( 'OTCSTicket: '.$ticket,

'Content-Type: application/x-www-form-urlencoded;');

$tmeCommand2= curl_init('http://localhost/alpha/cs.exe/api/v2/nodes');

curl_setopt($tmeCommand2, CURLOPT_FOLLOWLOCATION, TRUE);

curl_setopt($tmeCommand2, CURLOPT_CONNECTTIMEOUT, 10);

curl_setopt($tmeCommand2, CURLOPT_TIMEOUT, 10);

curl_setopt($tmeCommand2, CURLOPT_HTTPHEADER, $headers );

curl_setopt($tmeCommand2, CURLOPT_HEADER, false);

curl_setopt($tmeCommand2, CURLOPT_POSTFIELDS, $field);

curl_setopt($tmeCommand2, CURLOPT_CUSTOMREQUEST, 'POST');

curl_setopt($tmeCommand2, CURLOPT_RETURNTRANSFER, true);

curl_setopt($tmeCommand2, CURLOPT_VERBOSE, true);

$raw_response = curl_exec($tmeCommand2);

Comments

  • Appu Nair
    Appu Nair Member
    edited November 7, 2021 #2
    What is the cut & paste code suggested by Postman that is the best way to diagnose language specific issues …

    I have seen Java , c# as as well as many flavors of JavaScript but since I don’t do php don’t remember if postman suggests for that .

    Also I see curl used so if you you go to swagger of OTDS Another product you will see the utility using curl. Curl has probably no relation to php .

    Those were my thoughts @pookpl
  • As @Appu Nair recommend, i can write the code to upload the document.

    Thanks @Appu Nair