logo mazzal.net
selling diamonds made easy

Code Sample CSV String Upload

Here is an example how to use our API for automated stock upload in C#. The general idea is that you send your username and password together with the contents of your diamond stock file as a CSV formatted string. After you upload it will appear in your bulk upload list, but automatic processing happens asynchronously.

WebClient webClient = new WebClient();
NameValueCollection formData = new NameValueCollection();

string UploadCSVString = @"StockNumber,Shape,Weight,Color,Clarity,LAB" +
Environment.NewLine + "#AB-1001,Round,1.1,E,VVS1,GIA";

string URL = "https://www.mazzal.net/Api3/CsvStringUpload";
formData["username"] = "223344";
formData["password"] = "yourpassword";
formData["csvstockdata"] = UploadCSVString;

byte[] responseBytes = webClient.UploadValues(URL, "POST", formData);
string Result = Encoding.UTF8.GetString(responseBytes);

Console.Write("well done!");