Converting Python Script to Vb.NET - Involves Post and Input XML String
- by Jason Shoulders
I'm trying to convert a Python Script to Vb.Net. The Python Script appears to accept some XML input data and then takes it to a web URL and does a "POST". I tried some VB.NET code to do it, but I think my approach is off because I got an error back "BadXmlDataErr" plus I can't really format my input XML very well - I'm only doing string and value. The input XML is richer than that.
Here is an example of what the XML input data looks like in the Python script:
<obj is="MyOrg:realCommand_v1/" >
<int name="priority" val="1" />
<real name="value" val="9.5" />
<str name="user" val="MyUserName" />
<reltime name="overrideTime" val="PT60S"/>
</obj>
Here's the Vb.net code I attempted to convert that:
Dim reqparm As New Specialized.NameValueCollection
reqparm.Add("priority", "1")
reqparm.Add("value", "9.5")
reqparm.Add("user", "MyUserName")
reqparm.Add("overrideTime", "PT60S")
Using client As New Net.WebClient
Dim sTheUrl As String = "[My URL]"
Dim responsebytes = client.UploadValues(sTheUrl, "POST", MyReqparm)
Dim responsebody = (New System.Text.UTF8Encoding).GetString(responsebytes)
End Using
I feel like I should be doing something else. Can anyone point me to the right direction?