简体   繁体   中英

Read json data from azure website

I try to read data from azure website for my android application. But when i try to reach it gives me an error.

But when i look with this website i can see json data.

I can see all json data so truely. But somehow when i enter the url my browser i can't see the data. And my url is http://tcm-test-api.azurewebsites.net/api/movie/search?term=%22Batman%22&page=1

Try setting Content-Type to application/json;charset=utf-8 in your Http request header. In android when you create the HttpUrlConnection do it as follows

URL myURL = new URL(serviceURL);
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setRequestMethod("GET");
myURLConnection.setRequestProperty("Content-Type", "application/json;charset=utf-8");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM