My client has a Web-to-Lead form on their WordPress site that collects info and sends the data to Salesforce. Salesforce then creates a new record within a custom object.
What I want to do is create another form (not Web-to-Lead) that updates an existing record.
Is there a way that I can update an existing record via the Force.com REST API? Should I even be using it? I'm a WordPress developer, not a Salesforce developer, so I have little-to-no knowledge in this space.
I followed this tutorial and created a Connected App in a Sandbox (I don't want to accidentally update or delete real-world records). The Connected App's callback URL is to my local MAMP server that has a fake SSL script. I then supplied the tutorial code with my client ID and secret, logged into my Salesforce Sandbox at test.salesforce.com
, clicked "Allow," and I got this error:
Error: call to token URL https://test.salesforce.com/services/oauth2/token failed with status 400, response
It also says that the connection isn't secure enough:
Stronger security is required. To access this website, update your web browser or upgrade your operating system to support TLS 1.1 or TLS 1.2.
I went to this website that checks if TSL 1.0 is deactivated, and it told me it is.
Right now I'm just trying to get the API working correctly -- not even worrying about updating any records -- so I am calling this function within the demo_rest.php
file. What it's supposed to do is return all the Ids of all of the records within the Enquiry custom object.
function show_enquiries_by_id($instance_url, $access_token) {
$query = "SELECT Id from Enquiry__c";
$url = "$instance_url/services/data/v20.0/query?q=" . urlencode($query);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token"));
$json_response = curl_exec($curl);
curl_close($curl);
$response = json_decode($json_response, true);
$total_size = $response['totalSize'];
echo "$total_size record(s) returned<br/><br/>";
foreach ((array) $response['records'] as $record) {
echo $record['Id'] . ", " . $record['Name'] . "<br/>";
}
echo "<br/>";
}
The Connected App has the following permission: Access and manage your data
Web browser: Chrome 59.0.3071.115
OS: OSX Yosemite 10.10.5