function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shivendra Singh PawarShivendra Singh Pawar 

UPDATE RECORDS USING REST api AND PHP

Hi,
Greetings of the day!

I am working on PHP and Salesforce integration and I want to update records using PHP data table.

Table Showing records from  salesforce

Now I want to update records in salesforce when clicking on the checkbox.
And also try the below code. 
function update_account($id, $followup, $instance_url, $access_token) {
    $url = "$instance_url/services/data/v20.0/sobjects/Contact/$id";

    $content = json_encode(array("shivendra__FollowUp__c" => $followup));
    echo $content;
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token",
                "Content-type: application/json"));
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
    curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

    curl_exec($curl);

    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if ( $status != 204 ) {
        die("Error: call to URL $url failed with status $status, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
    }
    echo "<b>update_contact function</b>";
    echo "HTTP status $status updating Contact<br/><br/>";

    curl_close($curl);
}
But getting an error:

{"shivendra__FollowUp__c":null}[{"errorCode":"METHOD_NOT_ALLOWED","message":"HTTP Method 'PATCH' not allowed. Allowed are HEAD,GET,POST"}]Error: call to URL https://shivendra-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/Contact/ failed with status 405, curl_error , curl_errno 0

It would be great if some urgently help me...


Thanks and Regards 
Shivendra Singh Pawar