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" 
 
<system.web> 
   
  <httpRuntime executionTimeout="2000000"/> 
</system.web> 
 
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" 
 
<system.web> 
   
  <httpRuntime executionTimeout="2000000"/> 
</system.web> 
 
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
				
					<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <AuthenticationTicketHeader xmlns="http://technet.rapaport.com/">
      <Ticket></Ticket>
    </AuthenticationTicketHeader>
  </soap:Header>
  <soap:Body>
    <UploadLots xmlns="http://technet.rapaport.com/">
      <Parameters>
        <LotList>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",</LotList>
        <LotListFormat>Rapnet</LotListFormat>
        <ReplaceAll>false</ReplaceAll>
        <FirstRowHeaders>true</FirstRowHeaders>
        <ReportOption>None</ReportOption>
      </Parameters>
    </UploadLots>
  </soap:Body>
</soap:Envelope>
				
			
Delete Diamonds Sample Code
				
					<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Header>

<AuthenticationTicketHeader xmlns="http://technet.rapaport.com/">

<Ticket></Ticket>

</AuthenticationTicketHeader>

</soap:Header>

<soap:Body>

<DeleteLots xmlns="http://technet.rapaport.com/">

<Parameters>

<ByField>RapnetLotID</ByField>

<FieldValueList>144520794</FieldValueList>

</Parameters>

</DeleteLots>

</soap:Body>

</soap:Envelope>
				
			

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" 
 
<system.web> 
   
  <httpRuntime executionTimeout="2000000"/> 
</system.web> 
 
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" 
 
<system.web> 
   
  <httpRuntime executionTimeout="2000000"/> 
</system.web> 
 
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
				
			

Links & Help Articles

Accessibility