<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error uploading file with JSON request in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104989#M29732</link>
    <description>&lt;P&gt;i have this code but i can't upload file into enywhere.&lt;BR /&gt;can you give an example of&amp;nbsp;jsonData array syntax?&lt;BR /&gt;i have the default installation of alfresco and i have achieved to create direcory.&lt;BR /&gt;i cant find the way to upload file.&lt;BR /&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;&lt;BR /&gt;//API Url&lt;BR /&gt;$url = '192.168.1.1:8080/alfresco/s/api/upload?alf_ticket=TICKET_e0113b837d77e99b3e0a33da110e12be52bded4e';&lt;BR /&gt;&lt;BR /&gt;//Initiate cURL.&lt;BR /&gt;$ch = curl_init($url);&lt;BR /&gt;&lt;BR /&gt;//The JSON data.&lt;BR /&gt;$jsonData = array(&lt;BR /&gt;"filedata"=&amp;gt; "test.txt",&lt;BR /&gt;"siteid"=&amp;gt; "siteName",&lt;BR /&gt;"containerid"=&amp;gt; "documentLibrary",&lt;BR /&gt;"description"=&amp;gt; "A shiny new node"&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;//Encode the array into JSON.&lt;BR /&gt;$jsonDataEncoded = json_encode($jsonData);&lt;BR /&gt;&lt;BR /&gt;//Tell cURL that we want to send a POST request.&lt;BR /&gt;curl_setopt($ch, CURLOPT_POST, 1);&lt;BR /&gt;&lt;BR /&gt;//Attach our encoded JSON string to the POST fields.&lt;BR /&gt;curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);&lt;BR /&gt;&lt;BR /&gt;//Set the content type to application/json&lt;BR /&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));&lt;BR /&gt;&lt;BR /&gt;//Execute the request&lt;BR /&gt;$result = curl_exec($ch);&lt;/P&gt;&lt;P&gt;?&amp;gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Oct 2019 05:58:53 GMT</pubDate>
    <dc:creator>ni0ni0s</dc:creator>
    <dc:date>2019-10-24T05:58:53Z</dc:date>
    <item>
      <title>Error uploading file with JSON request</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104989#M29732</link>
      <description>&lt;P&gt;i have this code but i can't upload file into enywhere.&lt;BR /&gt;can you give an example of&amp;nbsp;jsonData array syntax?&lt;BR /&gt;i have the default installation of alfresco and i have achieved to create direcory.&lt;BR /&gt;i cant find the way to upload file.&lt;BR /&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;&lt;BR /&gt;//API Url&lt;BR /&gt;$url = '192.168.1.1:8080/alfresco/s/api/upload?alf_ticket=TICKET_e0113b837d77e99b3e0a33da110e12be52bded4e';&lt;BR /&gt;&lt;BR /&gt;//Initiate cURL.&lt;BR /&gt;$ch = curl_init($url);&lt;BR /&gt;&lt;BR /&gt;//The JSON data.&lt;BR /&gt;$jsonData = array(&lt;BR /&gt;"filedata"=&amp;gt; "test.txt",&lt;BR /&gt;"siteid"=&amp;gt; "siteName",&lt;BR /&gt;"containerid"=&amp;gt; "documentLibrary",&lt;BR /&gt;"description"=&amp;gt; "A shiny new node"&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;//Encode the array into JSON.&lt;BR /&gt;$jsonDataEncoded = json_encode($jsonData);&lt;BR /&gt;&lt;BR /&gt;//Tell cURL that we want to send a POST request.&lt;BR /&gt;curl_setopt($ch, CURLOPT_POST, 1);&lt;BR /&gt;&lt;BR /&gt;//Attach our encoded JSON string to the POST fields.&lt;BR /&gt;curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);&lt;BR /&gt;&lt;BR /&gt;//Set the content type to application/json&lt;BR /&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));&lt;BR /&gt;&lt;BR /&gt;//Execute the request&lt;BR /&gt;$result = curl_exec($ch);&lt;/P&gt;&lt;P&gt;?&amp;gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 05:58:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104989#M29732</guid>
      <dc:creator>ni0ni0s</dc:creator>
      <dc:date>2019-10-24T05:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error uploading file with JSON request</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104990#M29733</link>
      <description>&lt;P&gt;This is a working sample using the new REST API:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/43072054/upload-files-to-alfresco-using-php-and-curl" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/43072054/upload-files-to-alfresco-using-php-and-curl&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 08:21:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104990#M29733</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2019-10-25T08:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error uploading file with JSON request</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104991#M29734</link>
      <description>&lt;P&gt;thanks for your answer&lt;/P&gt;&lt;P&gt;but which is the relativePath?&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class="str"&gt;'relativePath'&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="str"&gt;'uploads'&lt;/SPAN&gt; &lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 05:43:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104991#M29734</guid>
      <dc:creator>ni0ni0s</dc:creator>
      <dc:date>2019-10-27T05:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error uploading file with JSON request</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104992#M29735</link>
      <description>&lt;P&gt;have you done this?? is this a working example for sure?&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;/P&gt;&lt;P&gt;ini_set('display_errors', 1);&lt;BR /&gt;ini_set('display_startup_errors', 1);&lt;BR /&gt;error_reporting(E_ALL);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$url = '&lt;A href="http://192.168.1.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-shared-/children?alf_ticket=TICKET_1063e54bc9fcb61071acf61e87de686ddf1aff3e" target="_blank" rel="nofollow noopener noreferrer"&gt;http://192.168.1.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-shared-/children?alf_ticket=TICKET_1063e54bc9fcb61071acf61e87de686ddf1aff3e&lt;/A&gt;';&lt;/P&gt;&lt;P&gt;$ch = curl_init();&lt;/P&gt;&lt;P&gt;$charray = array(&lt;BR /&gt;CURLOPT_USERPWD =&amp;gt; 'admin:admin',&lt;BR /&gt;CURLOPT_POST =&amp;gt; 1,&lt;BR /&gt;CURLOPT_POSTFIELDS =&amp;gt; array(&lt;BR /&gt;'filedata' =&amp;gt; new CURLFile('test.txt'),&lt;BR /&gt;'name' =&amp;gt; 'test.txt',&lt;BR /&gt;'relativePath' =&amp;gt; 'Sites/site1/documentLibrary'&lt;BR /&gt;),&lt;BR /&gt;CURLOPT_URL =&amp;gt; $url,&lt;BR /&gt;CURLOPT_RETURNTRANSFER =&amp;gt; true&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;curl_setopt_array($ch,$charray);&lt;/P&gt;&lt;P&gt;// execute post&lt;BR /&gt;$result = curl_exec($ch);&lt;/P&gt;&lt;P&gt;// close curl handle&lt;BR /&gt;curl_close($ch);&lt;/P&gt;&lt;P&gt;?&amp;gt;&lt;/P&gt;&lt;P&gt;the above returns nothing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 11:56:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-uploading-file-with-json-request/m-p/104992#M29735</guid>
      <dc:creator>ni0ni0s</dc:creator>
      <dc:date>2019-10-28T11:56:35Z</dc:date>
    </item>
  </channel>
</rss>

