shanekahkola Posted May 20, 2009 Posted May 20, 2009 (edited) I am struggling with the process of using an EXE app to access an XML source across the web. A game I play online offers the ability to access character information, item databases, etc. by using an online API. To my knowledge, here is how it works: The following URL should return an XML file that lists all of the characters on my account: http://api.eve-online.com/account/Characters.xml.aspx?userID=5050156&apiKey=13DC16F65B424DC4A9479C69A2DA9C1613A1D36EAA1F49A0B93380FAC6F55C69 <?xml version="1.0" encoding="UTF-8" ?> - <eveapi version="2"> <currentTime>2009-05-20 13:41:49</currentTime> - <result> - <rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID"> <row name="G1ggler" characterID="165109553" corporationName="University of Caille" corporationID="1000115" /> </rowset> </result> <cachedUntil>2009-05-20 14:41:49</cachedUntil> </eveapi> Here is what I would like to do. I want to be able to receive that XML file and parse it into fields on a form. This is not ASP.NET, this is an executable with VB code pages. I have a form that requests the userID (7-digit number) and the apiKey (encrypted hash key). Here is my source code: Dim rPost As WebRequest = WebRequest.Create("http://api.eve-online.com/account/Characters.xml.aspx") Dim sData As String = "userID=" & txUserID.Text & "&apiKey=" & txLimitedAPI.Text rPost.Method = WebRequestMethods.Http.Post Dim rsGet As WebResponse = rPost.GetResponse 'rsGet = rPost.GetResponse Dim sr As New StreamReader(rsGet.GetResponseStream(), Encoding.ASCII) MsgBox("xml data", MsgBoxStyle.Information, sr.ReadToEnd) When I execute the code, I get the following error: The remote server returned an error: (411) Length Required. The stack trace for the error is: " at System.Net.HttpWebRequest.GetResponse() at EveConnect.fNewProfile.bContinue_Click(Object sender, EventArgs e) in C:\Binaries\EXE.NET\EveConnect\EveConnect\fNewProfile.vb:line 13 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at EveConnect.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()" I have created an account that will allow you to see what is supposed to happen. Here is the userID and the apiKey: userID: 5050156 apiKey: 13DC16F65B424DC4A9479C69A2DA9C1613A1D36EAA1F49A0B93380FAC6F55C69 My guess is that I'm just not using the WebRequest.Http.Post properly, but Microsoft's documentation doesn't cover this very well. Any help would be greatly appreciated. Edited May 20, 2009 by shanekahkola Quote
Administrators PlausiblyDamp Posted May 21, 2009 Administrators Posted May 21, 2009 Try changing it to rPost.Method = WebRequestMethods.Http.Get Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
shanekahkola Posted May 21, 2009 Author Posted May 21, 2009 rPost.Method = WebRequestMethods.Http.Get You rock! Thank you for the advice - it worked beautifully. I'm sure I'll have questions down the road, but that suits my needs. I hope I will be able to actually contribute as I get to know the .NET platform. Thanks again. Quote
joe_pool_is Posted July 10, 2009 Posted July 10, 2009 I just wanted to say that you did an exellent job of describing your problem and providing visual aids. Wonderful job! Quote Avoid Sears Home Improvement
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.