01-17-2013 08:39 AM
After a long hours spend on it
myself and Michel de Cesaro come accross with this code
I really want to share because we didn't find not very good documentation on it so hopefully one day someone will be pleased
Code Bellow
UPDATE via SDATA from web using PHP+ CURL
UPDATE SDATA using PHP+ CURL just change as needed
<?php
$auth = "adminassword";
$url = 'http://ServerIPort/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')'; $data = '<?xml version="1.0" encoding="utf-8"?> <entry xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://schemas.sage.com/sdata/http/2008/1" xmlns="http://www.w3.org/2005/Atom"> <id>http://ServerIP
ort/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')</id> <title>False</title> <updated>2013-01-16T13:42:38.00+00:00</updated> <author> <name>SalesLogix</name> </author> <category term="resource" scheme="http://schemas.sage.com/sdata/categories" label="Resource" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')" rel="self" type="application/atom+xml; type=entry" title="Self" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')" rel="edit" type="application/atom+xml; type=entry" title="Edit" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')?format=html" rel="alternate" type="text/html" title="Alternate" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts/$schema" rel="schemas.sage.com/sdata/link-relations/schema" type="application/xml" title="Schema" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts/$template" rel="schemas.sage.com/sdata/link-relations/template" type="application/atom+xml; type=entry" title="Template" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts" rel="schemas.sage.com/sdata/link-relations/post" type="application/atom+xml; type=entry" title="Post" /> <link href="http://10.12.9.34/sdata/slx/dynamic/-/Contacts/$service" rel="schemas.sage.com/sdata/link-relations/service" type="application/atom+xml; type=feed" title="Service" /> <sdata:payload> <Contact sdata:key="C6UJ9A0001QV" sdata:uri="http://10.12.9.34/sdata/slx/dynamic/-/Contacts(\'C6UJ9A0001QV\')" sdata:lookup="http://10.12.9.34/sdata/slx/dynamic/-/Contacts" xmlns="http://schemas.sage.com/dynamic/2007"> <Contactid xsi:nil="true" /> <CreateUser xsi:nil="true" /> <CreateDate xsi:nil="true" /> <ModifyUser>ADMIN</ModifyUser> <ModifyDate>2013-01-16T13:42:38+00:00</ModifyDate> <Status>2013-01-16T13:42:38+00:00</Status> <FirstName>test</FirstName> <Contact sdata:key="C6UJ9A0001QV" sdata:uri="http://ServerIP
ort/sdata/slx/dynamic/-/contacts(\'C6UJ9A0001QV\')" sdata:uuid="00000000-0000-0000-0000-000000000000" sdata:lookup="http://10.12.9.34/sdata/slx/dynamic/-/contacts" /> </Contact> </sdata:payload> </entry>';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 12); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_USERPWD, $auth); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/atom+xml;type=entry,application/xml","Content-Type:application/atom+xml;type=entry"));
$result = curl_exec($ch); echo $result;
if ( curl_errno($ch) ) { $result = "ERROR -> " . curl_errno($ch) . ": " . curl_error($ch); } else { $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); switch($returnCode){ case 404: $result = "ERROR -> 404 Not Found"; break; default: break; } echo "<br><br>ERROR -> ".$returnCode; } curl_close($ch);
?>