|
-
Jul 1st, 2005, 04:03 AM
#1
Thread Starter
New Member
Upload Inventory To Amazon
Hi I'm almost there with this app to upload my inventory on Amazon. Their documentation says 'the body of the message should include the actual inventory file desired for upload'.
I've tried a few ways of attaching the files(rem'd out) (this is my 1st .net project!) but get 'error no file attached' in the response whatever approach I try.
Sub UploadInventory()
Dim postdata As String
Dim encoding As New ASCIIEncoding
Dim byte1 As Byte()
Dim mywebreq As HttpWebRequest
Dim mystream As Stream
Dim filename As String
Dim ActionName As String
ActionName = uploadInv
filename = "D:\Amazon\UploadInv.txt"
mywebreq = CType(HttpWebRequest.Create(ActionName), HttpWebRequest)
mywebreq.KeepAlive = False
mywebreq.Method = "POST"
mywebreq.Headers.Add("Content-Disposition", "attachment; Filename=D:\Amazon\Amazon.txt")
'postdata = "file" + Microsoft.VisualBasic.ChrW(61) + _
postdata = "D:\Amazon\Amazon.txt"
mywebreq.ContentLength = postdata.Length
mywebreq.ContentType = "application/txt"
'mywebreq.ContentType = "application/x-www-form-urlencoded"
mywebreq.Headers.Add("Cookie", ck)
mywebreq.Headers.Add("Authorization: Basic " & myUserPwd64)
mywebreq.Headers.Add("dev-t", myDevToken)
mywebreq.Headers.Add("UploadFor", "Marketplace")
mywebreq.Headers.Add("FileFormat", "TabDelimited")
mystream = mywebreq.GetRequestStream()
'byte1 = encoding.GetBytes(postdata)
'mystream.Write(byte1, 0, byte1.Length)
mystream.Flush()
Dim mywebrsp As HttpWebResponse = CType(mywebreq.GetResponse(), HttpWebResponse)
Dim streamResponse As Stream = mywebrsp.GetResponseStream()
Dim outfile As New FileStream(filename, FileMode.Create)
Dim streamRead As New StreamReader(streamResponse)
Dim readStr As String = streamRead.ReadToEnd()
outfile.Write(System.Text.Encoding.ASCII.GetBytes(readStr), 0, readStr.Length)
outfile.Close()
mywebrsp.Close()
End Sub
-
Jul 5th, 2005, 12:56 PM
#2
Thread Starter
New Member
Re: Upload Inventory To Amazon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|