我尝试将我的应用程序与ms链接起来。我完成ms登录,然后得到outlook日历id。在ms develop页面中,他们要求我向"https://graph.microsoft.com/v1.0/me/calendar“发送http请求。
我得到了:
com.android.volley.NoConnectionError: java.net.UnknownHostException:无法解析主机"graph.microsoft.com":没有与主机名关联的地址
String url = "https://graph.microsoft.com/v1.0/me/calendar";
final TextView textView = (TextView)findViewById(R.id.getcalendar);
RequestQueue queue = Volley.newRequestQueue(this);
JSONObject parameters = new JSONObject();
JsonObjectRequest jsObjRequest = new JsonObjectRequest
(Request.Method.GET, url, parameters, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
textView.setText("Response: " + response.toString());
Log.i("in onresponse","gdgd");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
Log.d("onErrorResponse", "Error: " + error.toString());
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer ");
return headers;
}
};
jsObjRequest.setRetryPolicy(new DefaultRetryPolicy(
3000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(jsObjRequest);发布于 2017-05-17 02:09:11
UnknowHostException是一个非常普遍的错误,因为当代理关闭、网络连接中断或DNS问题时。检查进程正在运行的会话,查看是否存在会话超时问题。
然而,https://graph.microsoft.com/v1.0/me/calendar似乎不是一个Get方法.尝试更改Get到Post方法
Request.Method.POST而不是Request.Method.GET
https://stackoverflow.com/questions/44014324
复制相似问题