Results 1 to 2 of 2

Thread: Upload Inventory To Amazon

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    6

    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



  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    6

    Re: Upload Inventory To Amazon

    - resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width