Working on a program that makes use of a third party API. That API can be found here: API v2 [AllardSoft Documentation]
I've gone to the vendor, and the vendor unfortunately can only be of so much help. The API they published does work and I've been able to verify it works via a *nix korn shell, using Curl, just like the examples they give.
I really should be able to do the same via VB.Net.
The code below executes without error if I change the ContentType to "plain/text". If I change it to "text/xml" I get an error: 401 (Unauthorized). Unfortunately it's not doing what it really needs to do, post the supplied XML string, and get in return (response) a new string of XML text that, according to the API, is the api_key value. I understand that unless you too have this FileTransfer Applicance, it may be hard to answer my question. However, I don't think the API does anything that many other service oriented web sites do, i.e. accept an xml stream, and respond back in an xml stream.
Any ideas where I might be going wrong? What I ultimately need to do is read the response as XML, iterate the key values in that response, and store the value in a variable for later use. Thanks.
I've gone to the vendor, and the vendor unfortunately can only be of so much help. The API they published does work and I've been able to verify it works via a *nix korn shell, using Curl, just like the examples they give.
I really should be able to do the same via VB.Net.
The code below executes without error if I change the ContentType to "plain/text". If I change it to "text/xml" I get an error: 401 (Unauthorized). Unfortunately it's not doing what it really needs to do, post the supplied XML string, and get in return (response) a new string of XML text that, according to the API, is the api_key value. I understand that unless you too have this FileTransfer Applicance, it may be hard to answer my question. However, I don't think the API does anything that many other service oriented web sites do, i.e. accept an xml stream, and respond back in an xml stream.
Any ideas where I might be going wrong? What I ultimately need to do is read the response as XML, iterate the key values in that response, and store the value in a variable for later use. Thanks.
Dim r As StreamReader Dim result As String Dim h As HttpWebRequest = WebRequest.Create("https://filetransfer.somewhere.com") Dim xml As String = "<?xml version=""1.0"" encoding=""UTF-8""?><user><email>someone@somewhere.com</email><password>somepassword</password></user>" Dim enc As New UTF8Encoding Dim byte1 As Byte() = enc.GetBytes(xml) h.Method = "POST" h.ContentType = "text/xml" h.ContentLength = byte1.Length Dim st As Stream = h.GetRequestStream() st.Write(byte1, 0, byte1.Length) st.Close() Dim response As WebResponse = h.GetResponse() r = New StreamReader(response.GetResponseStream) result = r.ReadToEnd txtResponse.Text = "" txtResponse.Text = result response.Close()