I need to upload a file with a webrequest and combine it with some other form data in the request. Today my post request looks like this:
 Protected Function PostData(ByRef url As String, ByRef POST As String, ByRef Cookie As System.Net.CookieContainer) As String
    Dim request As HttpWebRequest
    Dim response As HttpWebResponse
    request = CType(WebRequest.Create(url), HttpWebRequest)
    request.ContentType = "application/x-www-form-urlencoded"
    request.ContentLength = POST.Length
    request.Method = "POST"
    request.AllowAutoRedirect = False
    Dim requestStream As Stream = request.GetRequestStream()
    Dim postBytes As Byte() = Encoding.ASCII.GetBytes(POST)
    requestStream.Write(postBytes, 0, postBytes.Length)
    requestStream.Close()
    response = CType(request.GetResponse, HttpWebResponse)
    Return New StreamReader(response.GetResponseStream()).ReadToEnd()
End Function
The string post (in request.ContentLength) now contains this form-data:
"access_token=xxyyzzz"
Now I want also to add this form data parameters: file (a pdf file to upload) recipient_email (string value) recipient_name (string value)
How do I need to alter the PostData function to be able to post both the file and the string data in the webrequest?
Thanks for help!
Peter
