There are two request methods you can use to add and edit records in the database: HTTP PUT and POST.
Use the PUT method to update an existing entry in the database. For example, to update a customer contact record with new information you would use the PUT method.
Here's a C# sample using HTTP Web Request
using System;
using System.IO;
using System.Net;
class Test
{
static void Main()
{
string json = "...";
byte[] arr = System.Text.Encoding.UTF8.GetBytes(json);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/");
request.Method = "PUT";
request.ContentType = "text/json";
request.ContentLength = arr.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(arr, 0, arr.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string returnString = response.StatusCode.ToString();
Console.WriteLine(returnString);
}
}
Use the POST method to add a new entry to the database, whether it already exists or not. For example, you might use the POST method to add a customer to the company file. If the customer you're adding already exists, another record for the customer will be added.
Here's a PHP example using cURL
// Initiate curl
$ch = curl_init();
// Where you want to post data
$url = "https://api.myob.com/"; // Company File or Business URI
// Headers
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post
// Setup authentication
curl_setopt($ch, CURLOPT_USERPWD, 'administrator' . ":");
// Define what you want to post
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"Your JSON":"here"}');
// Return the output in string format
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute
$output = curl_exec ($ch);
curl_close ($ch); // Close curl handle
var_dump($output); // Show output
If you want to: