I need to send a document of a Software for Alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
viperboys
Active Member II

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @EddieMay 
Thanks for your valuable help. Yesterday I tried to do the same but I have this error.

{
    "exception""invalidArgument",
    "message""Invalid form encoding!"
}
I am doing these tests with Postman
URL: http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=45a0643c... SurprisedbjectTypeId&propertyValue[1]=cmis:document&alf_ticket=TICKET_bd5a46d1fcf87aca154220f959d19d141abc0903

Method POST
EddieMay
Alfresco Employee

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @viperboys,

I've just used Postman to upload two documents to my home  directory in Alfresco.

Here is the generated PHP code from Postman:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Documents/Alfresco - a developer led strategy.pptx')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Attached you can see the files in Share.

Here's the code for uploading a jpg file:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Downloads/eddie.may.jpg')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Hopefully this should give you a start to resolving your problem.

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
viperboys
Active Member II

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @EddieMay 

I am very grateful for your help. I am a little confused, this is because I am new to this area.

That php code was generated by Postman? How can I use it with postman? I have always used a URL, the method and send a JSON. This is how it worked for me but what you send me I don't know how to put it in Postman.

I hope you can help me. Thank you very much and happy day.

EddieMay
Alfresco Employee

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @viperboys,

Don't worry - we were all new to this at one time. Some of us (like me) still are!! 

The code I shared was acutally generated by Postman. The app has a "generate code" option - you can select the language & et voila! There are several languages available, including javascript such as Node. On my Mac the code button is to the right, below the Send button (see attached)

I'm thinking you can perhaps incorporate the url call & data into yourGravityFlow plugin WebHook.

HTH,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
EddieMay
Alfresco Employee

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @viperboys ,

In Postman I'd recommend getting the call to work - this will prove the concept that you can post a file to Alfresco using the Alfresco API.

Then in Postman you could begin to override the body of your working method to use JSON to include the file, authentication, etc. If you click on the body section and select Raw, you have json as an option (see attached).

HTH

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
viperboys
Active Member II

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @EddieMay 

Now it worked. Thank you very much for your valuable help.

God bless you.

EddieMay
Alfresco Employee

Re: I need to send a document of a Software for Alfresco

Jump to solution

Hi @viperboys,

Great news & happy to help. Have a great weekend! 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!