Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HttpWebRequest Syntax for Post method.

Status
Not open for further replies.

sd110404

Programmer
Nov 3, 2004
63
US
Hello,

Can someone please help me put this in place.

I have an external api that I am connecting to, to update some data (which is in XML format).

I have the following set of code to update the data

XmlElement ticket = doc["Ticket"]; // doc is xmldoc

foreach (XmlNode node in ticket.GetElementsByTagName("Custom_Field"))
{
if (node.Attributes["display-name"] != null && node.Attributes["display-name"].Value == "Summary")
{
node.InnerText = txtComment.Text; // overwriting my comment for summary
break;
}
}

I am not sure in using HTTPWebRequest and post method. to post these changes back to the uri.

I hope I am clear with my query. Please let me know if I should provide more info. Thanks for any help.

 
My guess the element you might miss is the way you set up the post data. This is how.
[1] Identify the request form variable name, figuratively say, x.
[2] Set up the buffer byte[] like this.
[tt] byte[] buffer=Encoding.Default.GetBytes("x="+ticket.OuterXml); //import System.Text[/tt]
[3] The rest is fairly standard stuff with HttpWebRequest, Stream, HttpWebResponse, StreamReader...etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top