AnsweredAssumed Answered

Calling a Boomi REST web service from C# code

Question asked by allan.ford577519 on Aug 29, 2017
Latest reply on Aug 29, 2017 by allan.ford577519

Hi ! - I wondered if anyone would be willing to share example C# code on calling a Boomi REST web service from a C# application ?   I know how to call a SOAP web service from C# e.g. as per this code example, but I am interested in calling a REST web service ..


C# example calling SOAP web service:


HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"http://awsuxboomi01t:9090/ws/soap");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";

XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soapenv:Envelope xmlns:soapenv="""" xmlns:wss="""">
using (Stream stream = webRequest.GetRequestStream())
using (WebResponse response = webRequest.GetResponse())
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
string soapResult = rd.ReadToEnd();




Regarding C# app calling a REST web service, I have tried C# code like this:



string url = "http://awsuxboomi01t:9090/ws/simple/getHello_information?hello_information=%22ABC%22";
HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url);
GETRequest.Method = "GET";
MessageBox.Show("Sending GET Request");
HttpWebResponse GETResponse = (HttpWebResponse)GETRequest.GetResponse();
Stream GETResponseStream = GETResponse.GetResponseStream();
StreamReader sr = new StreamReader(GETResponseStream);

MessageBox.Show("Response from Server");



but I get error returned:


(405) Method Not Allowed.