Code: Select all
try
{
WebClient wc = new WebClient();
string str;
var Url = "http://dev01.tnomer.ru:7000/private/api/dictionary/work/asd";
wc.Encoding = Encoding.UTF8;
wc.Headers.Set("Content-Type", "application/json");
str = wc.DownloadString(Url );
System.Windows.MessageBox.Show("ok" + str);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show("error!!! " + ex.ToString());
}
In emulator
---------------------------
---------------------------
error!!! System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at Application1.MainPage..ctor() in C:\Users\user\AppData\Local\Temporary Projects\Application1\MainPage.xaml.cs:line 28
---------------------------
ОК
---------------------------
in browser
ok{"id":["The value 'asd' is not valid."]}