Reputation: 4900
I've tried to rebuild the folloging very simple Post methode:
https:/XYZ.com/v01/example.html
At Winforms client it works perfekt like this:
WC = New Net.WebClient
Dim reqparm As New Specialized.NameValueCollection
reqparm.Add("DomainName", "XYZarco.com")
reqparm.Add("PIN", "1111")
Dim responsebytes() As Byte = WC.UploadValues(uri, "POST", reqparm) 'works
Dim responsebody As String = (New Text.UTF8Encoding).GetString(responsebytes) 'works
But on Windows Phone 7.1 it does not work because library does not support UploadValues. After research I found that:
Dim U As String = "https://XYZ.com/v01/api.asp"
Dim uri As New Uri(U, UriKind.Absolute)
If WC Is Nothing Then
WC = New WebClient
'WC.Headers("HttpRequestHeader.ContentType") = " text/html"
WC.Headers("HttpRequestHeader.ContentType") = "application/x-www-form-urlencoded"
WC.Encoding = System.Text.Encoding.UTF8
End If
Dim Params As String = "DomainName=xyz.com&PIN=1111"
WC.Headers("HttpRequestHeader.ContentLength") = Params.Length.ToString
WC.UploadStringAsync(uri, "POST", Params)
But data are not posted. Response means: . ERROR 01, DomainName not correct, Please insert the Gold website like Domain.com
Can someone help me out?
Upvotes: 0
Views: 332
Reputation: 39007
WC.Headers("HttpRequestHeader.ContentType")
HttpRequestHeader is an enumeration. Use it without quotes:
WC.Headers(HttpRequestHeader.ContentType)
Upvotes: 1