REST API: update
12.11.2022
286

Updates a single record via POST request.

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, editid3

 key column values

field1, field2

 field values to update the record

 

Example

Update fixedassets with fa_code (key column) 5001 setting description to be Desktop Computer.

curl -X POST "http://sureqrapp.nizamer.com/api/v1.php?table=fixedassets&action=update" -d "editid1=5001&editid2=45&description=Desktop Computer" -H "Content-Type: application/x-www-form-urlencoded"  

Sample success response:

{  
"success"true  
}  

 

Sample code

Updates the record in the fixedassets table where fa_code (key column) is 5001 and userid is 45 setting description to be Desktop Computer

PHP:

<?php
$headers = [
 'X-Auth-Token: f75sk32s29f5ag4j4s6z',
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sureqrapp.nizamer.com/api/v1.php?table=fixedassets&action=update",
CURLOPT_HTTPHEADER => $headers,
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' => '5001''editid2' => '45', 'description' => 'Desktop Computer'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>  


C# (RestSharp):

var client = new RestClient("https://sureqrapp.nizamer.com/api/v1.php?table=fixedassets&action=update");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("editid1", "5001");
request.AddParameter("editid2", "45");

request.AddParameter("description", "Desktop Computer");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);


JavaScript (jQuery):

var form = new FormData();
form.append("editid1""5001");
form.append("editid2""45");
form.append(
"description""Desktop Computer");
 
var settings = {
"url""https://sureqrapp.nizamer.com/api/v1.php?table=fixedassets&action=update",
"method""POST",
"timeout": 0,
"processData"false,
"mimeType""multipart/form-data",
"contentType"false,
"data": form
};
 
$.ajax(settings).done(function (response) {
console.log(response);
});

 

Was this article helpful?Yes (0)No (0)Thank you for your feedback!