Welcome to eStoreware GSA API.
Sample code:
static void Main(string[] args)
{
string fileName = "D:\\GSAtest\\temp\\requesta3.xml";
string uri = " https://api.premierofficesupplies.com/Repository/transPO ";
CallEDIService(uri,fileName);
}
/// <summary>
/// </summary>
/// <param name="uri"></param>
/// <param name="fileName"></param>
/// fileName is the local fullfile name, e.g fileName="D:\\GSAtest\\temp\\requesta3.xml"
/// uri is the post http(s) URL e.g uri = "https://api.premierofficesupplies.com/Repository/transPO"
/// <returns></returns>
static public void CallEDIService(string uri, string fileName)
{
WebRequest req = null;
WebResponse rsp = null;
try
{
req = WebRequest.Create(uri);
req.Method = "POST"; // Post method
req.ContentType = "text/xml"; // content type
// Wrap the request stream with a text-based writer
StreamWriter writer = new StreamWriter(req.GetRequestStream());
// Write the XML text into the stream
writer.WriteLine(GetTextFromXMLFile(fileName));
writer.Close();
// Send the data to server
rsp = req.GetResponse();
StreamReader reader = new StreamReader(rsp.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string rspSrting = reader.ReadToEnd();
reader.Close();
rsp.Close();
}
catch (WebException webEx)
{
string str = webEx.Message;
}
catch (Exception ex)
{
string str = ex.Message;
}
finally
{
}
}