Hello, i have a big problem. I need to use this web service: https://static.anaf.ro/static/10/Anaf/Informatii_R/documentatie_SWAsincron_01112017.txt
But they have so small documentation about it that i don’t really understund what should i send. I tried to send a request like this:
System.Net.WebRequest webreq = System.Net.WebRequest::Create("https://webservicesp.anaf.ro:/PlatitorTvaRest/api/v1/ws/tva");
System.IO.Stream streamstr,responsestr;
System.IO.StreamWriter streamWriter;
System.Net.WebResponse webresponse;
System.IO.StreamReader reader;
System.Exception ex;
str json = "{\"cui\":\" customerVatNumber\"," +
"\"data\":\"2018-03-07\"}";
webreq.set_Method("POST");
webreq.set_ContentType("application/json");
streamstr = webreq.GetRequestStream();
streamWriter = new System.IO.StreamWriter(streamstr);
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
streamWriter.Dispose();
try
{
webresponse = webreq.GetResponse();
responsestr = webresponse.GetResponseStream();
reader = new System.IO.StreamReader(responsestr);
info(reader.ReadToEnd());
}
catch(Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
But i have error about “unsupported media type”.
Can you help me? What is the best practice to consume Web Service via x++?
Thanks allot!