Legacy API - Upload Diamonds
Diamond Upload API
Automate diamond uploads to RapNet using one of our API’s:Â
XML
This is for .Net or Java developers who want to use SOAP for uploading and managing diamond inventory on RapNet.Â
Click here for a full-service description.Â
HTTP POST
You can upload diamond listings using HTTP POST to the following endpoints
Send a CSV formatted string.
       For example, “StockNumber, Shape, Weight, Color, Clarity\n\rStrok_1.3, Round, 2.1, D, VVS1”Â
       Endpoint: https://technet.rapaport.com:449/HTTP/Upload/Upload.aspx?Method=string
Upload a CSV File
      Endpoint: https://technet.rapaport.com:449/HTTP/Upload/Upload.aspx?Method=file
Note: You must authenticate before sending the data.Â
Here is the upload API codeÂ
Â
Web Request and CSV File
using System;Â
using System.Collections.Generic;Â
using System.Text;Â
using System.Net;Â
using System.IO;Â
using System.Collections.Specialized;Â
Â
namespace TechnetSamplesÂ
{Â
class ProgramÂ
{Â
static void Main(string[] args)Â
{Â
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string resultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
webClient.Dispose();Â
Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=file";Â
string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");Â
System.Net.WebRequest webRequest = System.Net.WebRequest.Create(URL);Â
Â
webRequest.Method = "POST";Â
webRequest.ContentType = "multipart/form-data; boundary=" + boundary;Â
Â
string FilePath = "C:\\test.csv";Â
formData.Clear();Â
formData["ticket"] = resultAuthTicket;Â
formData["ReplaceAll"] = "false";Â
Â
Stream postDataStream = GetPostStream(FilePath, formData, boundary);Â
Â
webRequest.ContentLength = postDataStream.Length;Â
Stream reqStream = webRequest.GetRequestStream();Â
Â
postDataStream.Position = 0;Â
Â
byte[] buffer = new byte[1024];Â
int bytesRead = 0;Â
Â
while ((bytesRead = postDataStream.Read(buffer, 0, buffer.Length)) != 0)Â
{Â
reqStream.Write(buffer, 0, bytesRead);Â
}Â
Â
postDataStream.Close();Â
reqStream.Close();Â
Â
StreamReader sr = new StreamReader(webRequest.GetResponse().GetResponseStream());Â
string Result = sr.ReadToEnd();Â
}Â
Â
private static Stream GetPostStream(string filePath, NameValueCollection formData, string boundary)Â
{Â
Stream postDataStream = new System.IO.MemoryStream();Â
Â
//adding form dataÂ
string formDataHeaderTemplate = Environment.NewLine + "--" + boundary + Environment.NewLine +Â
"Content-Disposition: form-data; name=\"{0}\";" + Environment.NewLine + Environment .NewLine + "{1}";Â
Â
foreach (string key in formData.Keys)Â
{Â
byte[] formItemBytes = System.Text.Encoding.UTF8.GetBytes(string.Format(formDataHeaderTemplate,Â
key, formData[key]));Â
postDataStream.Write(formItemBytes, 0, formItemBytes.Length);Â
}Â
Â
//adding file dataÂ
FileInfo fileInfo = new FileInfo(filePath);Â
Â
string fileHeaderTemplate = Environment.NewLine + "--" + boundary + Environment.NewLine +Â
"Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" +Â
Environment.NewLine + "Content-Type: application/vnd.ms-excel" + Environment.NewLine + Environment.NewLine;Â
Â
byte[] fileHeaderBytes = System.Text.Encoding.UTF8.GetBytes(string.Format(fileHeaderTemplate,Â
"UploadCSVFile", fileInfo.FullName));Â
Â
postDataStream.Write(fileHeaderBytes, 0, fileHeaderBytes.Length);Â
Â
FileStream fileStream = fileInfo.OpenRead();Â
Â
byte[] buffer = new byte[1024];Â
Â
int bytesRead = 0;Â
Â
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)Â
{Â
postDataStream.Write(buffer, 0, bytesRead);Â
}Â
Â
fileStream.Close();Â
Â
byte[] endBoundaryBytes = System.Text.Encoding.UTF8.GetBytes("--" + boundary + "--");Â
postDataStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);Â
Â
return postDataStream;Â
}Â
}Â
}Â
WebClient and CSV String
string UploadCSVString = @"StockNumber,Shape,Weight,Color,Clarity" +Â
Environment.NewLine + "1234Eli,Round,2.0,F,VVS1"; //CSV formaÂ
Â
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string ResultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
Â
webClient.Dispose();Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=string";Â
formData.Clear();Â
formData["ticket"] = ResultAuthTicket;Â
formData["UploadCSVString"] = UploadCSVString;Â
formData["ReplaceAll"] = "false";Â
Â
responseBytes = webClient.UploadValues(URL, "POST", formData);Â
string Result = Encoding.UTF8.GetString(responseBytes);
WebClient and CSV File
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string ResultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
Â
webClient.Dispose();Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=file&ReplaceAll=false&ticket=" + ResultAuthTicket;Â
formData.Clear();Â
Â
responseBytes = webClient.UploadFile(URL, "POST", "C:\\test.csv");Â
string Result = Encoding.UTF8.GetString(responseBytes);Â
WebServices – Framework 4.0
//in your binding setting increacse the timeout and buffer sizesÂ
closeTimeout="00:05:00" openTimeout="00:05:00"Â
receiveTimeout="00:10:00" sendTimeout="00:05:00"Â
maxBufferSize="65536" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"Â
Â
Â
  Â
   Â
Â
Â
DiamondManagerSoapClient webServiceManager = new DiamondManagerSoapClient();Â
Â
//This must be done in HTTPS protocolÂ
AuthenticationTicketHeader ticket = webServiceManager.Login("myUser", "myPassword");Â
Â
//After log in you will receive an encrypted ticket with your credentials. This will be used to authenticate your session.Â
//Now you can choose to change the protocol to HTTP so it works faster.Â
string oldAddress = webServiceManager.Endpoint.Address.ToString();Â
string newAddress = "http" + webServiceManager.Endpoint.Address.ToString().Substring(5);Â
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(newAddress);Â
webServiceManager.Endpoint.Address = address;Â
Â
UploadLotsParameters uploadManager = new UploadLotsParameters();Â
Â
uploadManager.FirstRowHeaders = true;Â
Â
string fileContent = File.ReadAllText(@"FilePath\File.csv");Â
Â
//indicates if the first row in the file contains headersÂ
uploadManager.LotList = fileContent;Â
Â
//indicates if to replace the this upload or to add it to the existing inventoryÂ
uploadManager.ReplaceAll = true;Â
Â
UploadLotsResult ressult = webServiceManager.UploadLots(ticket,uploadManager);Â
Â
//get your entire inventory in RapNetÂ
GetLotsResult lots = webServiceManager.GetLots(ticket);Â
Â
WebService Certificate Uploads – Framework 4.0
//in your binding setting increacse the timeout and buffer sizesÂ
closeTimeout="00:05:00" openTimeout="00:05:00"Â
receiveTimeout="00:10:00" sendTimeout="00:05:00"Â
maxBufferSize="65536" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"Â
Â
Â
  Â
   Â
Â
Â
DiamondManagerSoapClient webServiceManager = new DiamondManagerSoapClient();Â
Â
//This must be done in HTTPS protocolÂ
AuthenticationTicketHeader ticket = webServiceManager.Login("myUser", "myPassword");Â
Â
//After log in you will receive a encrypted ticket with your credentials. This will be used to authenticate your session.Â
//Now you can choose to change the protocol to HTTP so it works faster.Â
string oldAddress = webServiceManager.Endpoint.Address.ToString();Â
string newAddress = "http" + webServiceManager.Endpoint.Address.ToString().Substring(5);Â
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(newAddress);Â
webServiceManager.Endpoint.Address = address;Â
Â
//uploading image or zip filesÂ
Â
UploadFilesParameters ufp = new UploadFilesParameters();Â
Â
ufp.FileName = "Test.jpg"; //or Test.zipÂ
Â
ufp.FileContents = File.ReadAllBytes(@"C:\Test.jpg");//or Test.zipÂ
ufp.FileUploadType = FileUploadTypes.Cert;Â
Â
UploadFilesResult sr = webServiceManager.UploadFiles(ticket,ufp);;Â
Â
if (sr.InvalidFilesCount > 0)Â
{Â
//if it is a zip file you can get more then one file resultÂ
  foreach (FileUploadInfo fileinfo in sr.InvalidFiles)Â
  {Â
    string FileName = fileinfo.FileName;Â
    string ImageType = fileinfo.ImageType.ToString();Â
    string Url = fileinfo.Url;Â
  }Â
}Â
else if (sr.ValidFilesCount > 0)Â
{Â
//if it is a zip file you can get more then one file resultÂ
  foreach (FileUploadInfo fileinfo in sr.ValidFiles)Â
  {Â
    string FileName = fileinfo.FileName;Â
    string ImageType = fileinfo.ImageType.ToString();Â
    string Url = fileinfo.Url;Â
  }Â
}Â
Sample Codes
These are the most commonly used Diamond Upload APIs.Â
Click here for a complete list of API codes for uploading diamonds
The placeholders shown need to be replaced with actual values.
Upload Single Diamond Sample Code
Stock #,Availability,Shape,Weight,Color,Clarity,Cut Grade,Polish,Symmetry,Fluorescence Intensity,Fluorescence Color,Measurements,Lab,Certificate #,Treatment,RapNet Price,Rapnet Discount %,Cash Price,Cash Price Discount %,Fancy Color,Fancy Color Intensity,Fancy Color Overtone,Depth %,Table %,Girdle Thin,Girdle Thick,Girdle %,Girdle Condition,Culet Size,Culet Condition,Crown Height,Crown Angle,Pavilion Depth,Pavilion Angle,Laser Inscription,Comment,Shade,Black Inclusion,Center Inclusion,Milky,Key To Symbols,Country,State,City,Is Matched Pair Separable,Pair Stock #,Allow RapLink Feed,Parcel Stones,Certificate Filename,Diamond Image,3D File,Member Comment,Trade Show
IT-496,M,RBC,0.5,"H","I1","EX","VG","VG","NON",,"5.0600-5.0500*3.1400","GIA","2287209184",,1276.2,-29.1,,,"",,,62,58,,,0.04,,NON,,0.15,36,0.43,40.8,"","NO BGM 100% EYE CLEAN SONE IN HONG KONG",,,,,"TWINNING WISP FEATHER",HONG KONG,,,,,,,,http://www.example.hk/diamonddetail.php?pno=IT-496,,"STONE IN HK CONTACT Jone Doe +852123456781, QQ ID: 1234567890, WECHAT ID: Jone763",
Rapnet
false
true
None
Delete Diamonds Sample Code
RapnetLotID
144520794
C# Upload Diamonds Sample Code
Web Request and CSV File
using System;Â
using System.Collections.Generic;Â
using System.Text;Â
using System.Net;Â
using System.IO;Â
using System.Collections.Specialized;Â
Â
namespace TechnetSamplesÂ
{Â
class ProgramÂ
{Â
static void Main(string[] args)Â
{Â
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string resultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
webClient.Dispose();Â
Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=file";Â
string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");Â
System.Net.WebRequest webRequest = System.Net.WebRequest.Create(URL);Â
Â
webRequest.Method = "POST";Â
webRequest.ContentType = "multipart/form-data; boundary=" + boundary;Â
Â
string FilePath = "C:\\test.csv";Â
formData.Clear();Â
formData["ticket"] = resultAuthTicket;Â
formData["ReplaceAll"] = "false";Â
Â
Stream postDataStream = GetPostStream(FilePath, formData, boundary);Â
Â
webRequest.ContentLength = postDataStream.Length;Â
Stream reqStream = webRequest.GetRequestStream();Â
Â
postDataStream.Position = 0;Â
Â
byte[] buffer = new byte[1024];Â
int bytesRead = 0;Â
Â
while ((bytesRead = postDataStream.Read(buffer, 0, buffer.Length)) != 0)Â
{Â
reqStream.Write(buffer, 0, bytesRead);Â
}Â
Â
postDataStream.Close();Â
reqStream.Close();Â
Â
StreamReader sr = new StreamReader(webRequest.GetResponse().GetResponseStream());Â
string Result = sr.ReadToEnd();Â
}Â
Â
private static Stream GetPostStream(string filePath, NameValueCollection formData, string boundary)Â
{Â
Stream postDataStream = new System.IO.MemoryStream();Â
Â
//adding form dataÂ
string formDataHeaderTemplate = Environment.NewLine + "--" + boundary + Environment.NewLine +Â
"Content-Disposition: form-data; name=\"{0}\";" + Environment.NewLine + Environment .NewLine + "{1}";Â
Â
foreach (string key in formData.Keys)Â
{Â
byte[] formItemBytes = System.Text.Encoding.UTF8.GetBytes(string.Format(formDataHeaderTemplate,Â
key, formData[key]));Â
postDataStream.Write(formItemBytes, 0, formItemBytes.Length);Â
}Â
Â
//adding file dataÂ
FileInfo fileInfo = new FileInfo(filePath);Â
Â
string fileHeaderTemplate = Environment.NewLine + "--" + boundary + Environment.NewLine +Â
"Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" +Â
Environment.NewLine + "Content-Type: application/vnd.ms-excel" + Environment.NewLine + Environment.NewLine;Â
Â
byte[] fileHeaderBytes = System.Text.Encoding.UTF8.GetBytes(string.Format(fileHeaderTemplate,Â
"UploadCSVFile", fileInfo.FullName));Â
Â
postDataStream.Write(fileHeaderBytes, 0, fileHeaderBytes.Length);Â
Â
FileStream fileStream = fileInfo.OpenRead();Â
Â
byte[] buffer = new byte[1024];Â
Â
int bytesRead = 0;Â
Â
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)Â
{Â
postDataStream.Write(buffer, 0, bytesRead);Â
}Â
Â
fileStream.Close();Â
Â
byte[] endBoundaryBytes = System.Text.Encoding.UTF8.GetBytes("--" + boundary + "--");Â
postDataStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);Â
Â
return postDataStream;Â
}Â
}Â
}Â
WebClient and CSV String
string UploadCSVString = @"StockNumber,Shape,Weight,Color,Clarity" +Â
Environment.NewLine + "1234Eli,Round,2.0,F,VVS1"; //CSV formaÂ
Â
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string ResultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
Â
webClient.Dispose();Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=string";Â
formData.Clear();Â
formData["ticket"] = ResultAuthTicket;Â
formData["UploadCSVString"] = UploadCSVString;Â
formData["ReplaceAll"] = "false";Â
Â
responseBytes = webClient.UploadValues(URL, "POST", formData);Â
string Result = Encoding.UTF8.GetString(responseBytes);
WebClient and CSV File
string URLAuth = "https://technet.rapaport.com/HTTP/Authenticate.aspx";Â
WebClient webClient = new WebClient();Â
Â
NameValueCollection formData = new NameValueCollection();Â
formData["Username"] = "myUser";Â
formData["Password"] = "myPassword";Â
Â
byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);Â
string ResultAuthTicket = Encoding.UTF8.GetString(responseBytes);Â
Â
webClient.Dispose();Â
string URL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=file&ReplaceAll=false&ticket=" + ResultAuthTicket;Â
formData.Clear();Â
Â
responseBytes = webClient.UploadFile(URL, "POST", "C:\\test.csv");Â
string Result = Encoding.UTF8.GetString(responseBytes);Â
WebServices – Framework 4.0
//in your binding setting increacse the timeout and buffer sizesÂ
closeTimeout="00:05:00" openTimeout="00:05:00"Â
receiveTimeout="00:10:00" sendTimeout="00:05:00"Â
maxBufferSize="65536" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"Â
Â
Â
  Â
   Â
Â
Â
DiamondManagerSoapClient webServiceManager = new DiamondManagerSoapClient();Â
Â
//This must be done in HTTPS protocolÂ
AuthenticationTicketHeader ticket = webServiceManager.Login("myUser", "myPassword");Â
Â
//After log in you will receive an encrypted ticket with your credentials. This will be used to authenticate your session.Â
//Now you can choose to change the protocol to HTTP so it works faster.Â
string oldAddress = webServiceManager.Endpoint.Address.ToString();Â
string newAddress = "http" + webServiceManager.Endpoint.Address.ToString().Substring(5);Â
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(newAddress);Â
webServiceManager.Endpoint.Address = address;Â
Â
UploadLotsParameters uploadManager = new UploadLotsParameters();Â
Â
uploadManager.FirstRowHeaders = true;Â
Â
string fileContent = File.ReadAllText(@"FilePath\File.csv");Â
Â
//indicates if the first row in the file contains headersÂ
uploadManager.LotList = fileContent;Â
Â
//indicates if to replace the this upload or to add it to the existing inventoryÂ
uploadManager.ReplaceAll = true;Â
Â
UploadLotsResult ressult = webServiceManager.UploadLots(ticket,uploadManager);Â
Â
//get your entire inventory in RapNetÂ
GetLotsResult lots = webServiceManager.GetLots(ticket);Â
Â
WebService Certificate Uploads – Framework 4.0
//in your binding setting increacse the timeout and buffer sizesÂ
closeTimeout="00:05:00" openTimeout="00:05:00"Â
receiveTimeout="00:10:00" sendTimeout="00:05:00"Â
maxBufferSize="65536" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"Â
Â
Â
  Â
   Â
Â
Â
DiamondManagerSoapClient webServiceManager = new DiamondManagerSoapClient();Â
Â
//This must be done in HTTPS protocolÂ
AuthenticationTicketHeader ticket = webServiceManager.Login("myUser", "myPassword");Â
Â
//After log in you will receive a encrypted ticket with your credentials. This will be used to authenticate your session.Â
//Now you can choose to change the protocol to HTTP so it works faster.Â
string oldAddress = webServiceManager.Endpoint.Address.ToString();Â
string newAddress = "http" + webServiceManager.Endpoint.Address.ToString().Substring(5);Â
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(newAddress);Â
webServiceManager.Endpoint.Address = address;Â
Â
//uploading image or zip filesÂ
Â
UploadFilesParameters ufp = new UploadFilesParameters();Â
Â
ufp.FileName = "Test.jpg"; //or Test.zipÂ
Â
ufp.FileContents = File.ReadAllBytes(@"C:\Test.jpg");//or Test.zipÂ
ufp.FileUploadType = FileUploadTypes.Cert;Â
Â
UploadFilesResult sr = webServiceManager.UploadFiles(ticket,ufp);;Â
Â
if (sr.InvalidFilesCount > 0)Â
{Â
//if it is a zip file you can get more then one file resultÂ
  foreach (FileUploadInfo fileinfo in sr.InvalidFiles)Â
  {Â
    string FileName = fileinfo.FileName;Â
    string ImageType = fileinfo.ImageType.ToString();Â
    string Url = fileinfo.Url;Â
  }Â
}Â
else if (sr.ValidFilesCount > 0)Â
{Â
//if it is a zip file you can get more then one file resultÂ
  foreach (FileUploadInfo fileinfo in sr.ValidFiles)Â
  {Â
    string FileName = fileinfo.FileName;Â
    string ImageType = fileinfo.ImageType.ToString();Â
    string Url = fileinfo.Url;Â
  }Â
}Â
VBA
Upload using HTTP webclient and CSV file
Public Sub UploadRap()Â
    Dim strPost As StringÂ
    Dim objHTTP, replyTXT As StringÂ
    Dim AuthenticationTicket As StringÂ
    AuthenticationTicket = ""Â
    objHTTP = CreateObject("Msxml2.ServerXMLHTTP")Â
    strPost = "https://technet.rapaport.com/HTTP/Authenticate.aspx"Â
    'Get authentication ticket:Â
    objHTTP.Open("POST", strPost, False)Â
    Call objHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")Â
    objHTTP.send("Username=username&Password=password")Â
    replyTXT = objHTTP.responseTextÂ
    If objHTTP.Status = "200" Then 'successÂ
    AuthenticationTicket = replyTXTÂ
    ElseÂ
    'authentication failed, you need to deal with this.Â
    AuthenticationTicket = ""Â
    End IfÂ
    StopÂ
    Dim DestURL As StringÂ
    DestURL = "http://technet.rapaport.com/HTTP/Upload/Upload.aspx?Method=file"Â
    DestURL = DestURL & "&ticket=" + AuthenticationTicketÂ
    DestURL = DestURL & "&ReplaceAll=true&FirstRowHeaders=true&LotListFormat=Rapnet"Â
    Dim FileName As StringÂ
    FileName = "c:\stock.csv"Â
    UploadFile(DestURL, FileName, "Stock")Â
End SubÂ
Â
Sub UploadFile(ByVal DestURL As String, ByVal FileName As String, _Â
    Optional ByVal FieldName As String = "File")Â
    Dim sFormData As String, D As StringÂ
    StopÂ
    'Boundary of fields.Â
    'Be sure this string is Not In the source fileÂ
    Const Boundary As String = "---------------------------0123456789012"Â
    'Get source file As a string.Â
    sFormData = GetFile(FileName)Â
Â
    'Build source form with file contentsÂ
    D = "--" & Boundary & vbCrLfÂ
    D = D & "Content-Disposition: form-data; name=""" & FieldName & """;"Â
    D = D & " filename=""" & FileName & """" & vbCrLfÂ
    D = D & "Content-Type: application/upload" & vbCrLf & vbCrLfÂ
    D = D & sFormDataÂ
    D = D & vbCrLf & "--" & Boundary & "--" & vbCrLfÂ
Â
    'Post the data To the destination URLÂ
    IEPostStringRequest(DestURL, D, Boundary)Â
End SubÂ
Â
Â
'sends URL encoded form data To the URL using IEÂ
Sub IEPostStringRequest(ByVal URL As String, ByVal FormData As String, ByVal Boundary As String)Â
    'Create InternetExplorerÂ
    Dim WebBrowser : WebBrowser = CreateObject("InternetExplorer.Application")Â
Â
    'You can uncoment Next line To see form resultsÂ
    WebBrowser.Visible = TrueÂ
Â
    'Send the form data To URL As POST requestÂ
    Dim bFormData() As ByteÂ
    ReDim bFormData(Len(FormData) - 1)Â
    bFormData = StrConv(FormData, vbFromUnicode)Â
    WebBrowser.Navigate(URL, , , bFormData, _Â
    "Content-Type: multipart/form-data; boundary=" & Boundary & vbCrLf)Â
    Do While WebBrowser.BusyÂ
    ' Sleep 100Â
    DoEvents()Â
    LoopÂ
    WebBrowser.Quit()Â
End SubÂ
Â
    'read binary file As a string valueÂ
Function GetFile(ByVal FileName As String) As StringÂ
    Dim FileContents() As Byte, FileNumber As IntegerÂ
    ReDim FileContents(FileLen(FileName) - 1)Â
    FileNumber = FreeFile()Â
    Open FileName For Binary As FileNumberÂ
    Get FileNumber, , FileContentsÂ
    Close(FileNumber)Â
    GetFile = StrConv(FileContents, vbUnicode)Â
End Function