c# - Create XML file from REST response -
i have following method making rest request returns data in xml format -
public void test() { string requesturi = string.empty; try { requesturi = string.format("uri/{0}?locales={1}", "test", "en-gb"); httpclient client = new httpclient(); client.baseaddress = new uri(requesturi); httpresponsemessage response = client.getasync(requesturi).result; if (response.issuccessstatuscode) { string content = response.content.readasstringasync().result; // want create xml file here this.writetofile(content); } } catch (exception) { throw; } }
how can create xml file response got api?
since content xml change this.writetofile(content)
to
file.writealltext("foo.xml", content);
also try {} catch (exception e) {throw e}
bad. rethrowing loose stack information. nothing , thrown exceptions bubble caller.
Comments
Post a Comment