c# - Trying to access a Microsoft web-service causes a 400 Bad Request error -
i'm trying use microsoft translator webservice in application. though when try language names according example given @ http://msdn.microsoft.com/en-us/library/ff512414.aspx, (400) bad request error when try language names.
the uri use is:
private const string languagestring = "http://api.microsofttranslator.com/v2/http.svc/getlanguagenames"; private string[] usablelanguages = { "en", "nl", "es", "de" }; // create uri use. string getlanguages = string.empty; getlanguages = languagestring + string.format("?appid={0}&locale;=en", appkey); uri langrequest = new uri(getlanguages); httpwebrequest req = (httpwebrequest)webrequest.create(langrequest);
after use datacontractserializer , stream webrequest send request web service. when try response webrequest, (400) bad request error.
webresponse response = null; try { // causes exception. response = req.getresponse(); } catch (webexception e) { messagebox.show(e.tostring()); } { if (response != null) { response.close(); response = null; } }
if has idea, please tell me.
after further development, know error lies locale pass along uri. after further dissecting of webexception, status code protocolerror, , message "message: 'locale' must valid language". however, thought 'en' valid language... :/
Comments
Post a Comment