Can anybody provide an example of how to use the POST methods of REST API in PHP? I am able to do the GET methods (getDataField, etc.), but whenever I try a POST method (create, update) I am unsuccessful. The latest error I am getting is "Cannot parse XML input: ". Here's the PHP code: The results from the above code is: I've tried different methods of defining the XML [ $xml = simplexml_load_string($string); ] but I am getting the same error. Thanks
I confirm that PHP curl request does not go through REST server. I will investigate and fix the problem ASAP.
I've added another implementations for these APIs - create2 and update2. They take HTTP parameters only, no XML. Please let me know how this works for you (you still need to use POST).
I tried again using update2 and a parameter string instead of XML. Now I am getting an "OK" status - but the update was never actually performed. I even tried changing the query string to try an invalid field name and it still returns "OK". I may be doing something wrong as I'm not too familiar with curl.
Code:
/*
* LOG IN
*/
$uname = "MY_USERNAME";
$pword = "MY_PASSWORD";
echo "\n\nLogging in...\n";
$url = 'http://www.rollbase.com/rest/api/login?loginName='.$uname.'&password=' .$pword;
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$respXML = new SimpleXMLElement($response);
$sessionID = $respXML->sessionId;
echo "-->Logged in // SESSION ID: " . $sessionID;
/*
* UPDATE RECORD
*/
echo "\n\nUpdating record....";
$url = 'http://www.rollbase.com/rest/api/update2?sessionId=' . $sessionID;
$params = '&id=14270115&&useIds=false&fieldName=name
I've also tried updating regular text fields and picklist fields - with the same result. It says "OK" but when I look at the record in Rollbase or with getDataField it has the original value.
May be I did not make documentation clear enough: you should use pairs like
&admin_test_field=RESTUpdated
Actual parameter name is your field's name. If parameter's name is invalid the system will ignore it.
Are you trying update just a single field? I will provide setField API for that.
Ah, OK. That works.
Thanks!