Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > ASPRunnerPro's REST API

REST API: update

Scroll Prev Next More

Updates a single record via POST request.

 

Data is passed as key-value pairs in the body of the request. Fields to be updated are sent as fieldname=value&fieldname1=value1 list.

 

Arguments
 

table

the table name.

action

update

editid1, editid2, ...

key column values

field1, field2, ...

field values to update the record

Example

 

Update customer with CustomerID (key column) KOENE setting ContactName to be Bill Gates.

 

curl -X POST "http://localhost:8086/api/v1.asp?table=customers&action=update" -d "editid1=KOENE&ContactName=Bill Gates" -H "Content-Type: application/x-www-form-urlencoded"  

 

 

Sample success response:

 

{  
"success": true  
}  

 

Sample code

Updates the record in the customers table where CustomerID (key column) is KOENE setting ContactName to be Bill Gates

 

 

PHP code:

 

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
 CURLOPT_URL => "http://localhost:8086/api/v1.asp?table=customers&action=update",
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "POST",
 CURLOPT_POSTFIELDS => array('editid1' => 'KOENE','ContactName' => 'Bill Gates'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>  

 

 

C# code (using RestCharp):

 

var client = new RestClient("http://localhost:8086/api/v1.asp?table=customers&action=update");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("editid1", "KOENE");
request.AddParameter("ContactName", "Bill Gates");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

 

 

JavasScript code (jQuery):

 

var form = new FormData();
form.append("editid1", "KOENE");
form.append("ContactName", "Bill Gates");
 
var settings = {
"url": "http://localhost:8086/api/v1.asp?table=customers&action=update",
"method": "POST",
"timeout": 0,
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
 
$.ajax(settings).done(function (response) {
 console.log(response);
});