You need to sign in to do that
Don't have an account?
redavis13
Performing a HTTP Post to Salesforce
Has anyone posted xml to Salesforce with .NET integration? If so do you have any examples of the process for doing this and passing the sessionid in the session header after getting it from the login binding?
I've only tried posting csv... but I would imagine that posting xml would just be a different contentType
This example is an "upsert", but if you're doing an "insert" you can omit the externalIdFieldName
For more help take a look at this document...
http://www.salesforce.com/us/developer/docs/api_asynchpre/api_bulk.pdf
//** Prepare request content
XmlDocument doc = new XmlDocument();
string str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">" +
"<operation>upsert</operation>" +
"<object>" + objectName + "</object>" +
"<externalIdFieldName>" + externalId + "</externalIdFieldName>" +
"<contentType>CSV</contentType>" +
"</jobInfo>";
doc.LoadXml(str);
//** Prepare Uri (get serverUrl from login response)
string uri = serverUrl.Substring(0, serverUrl.IndexOf("services")) + "services/async/22.0/job";
//** Prepare WebRequest headers
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "application/xml; charset=UTF-8";
req.Headers.Add("X-SFDC-Session", sessionId);
//** Load request document into WebRequest
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
//** Perform WebRequest
WebResponse resp = req.GetResponse();