【问题标题】:Android Communicate with wit.aiAndroid 与 wit.ai 通信
【发布时间】:2017-11-21 04:05:55
【问题描述】:

我正在尝试使用 Volley 与 wit.AI 建立联系。但是,我得到的只是 400 错误

public void makeRequest(String url) {
    RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
    StringRequest postRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Toast.makeText(MainActivity.this, "YOU'RE TOAST", Toast.LENGTH_SHORT).show();
            Log.d("accessToken:", response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            Log.d("error:", volleyError.toString());

        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<String, String>();
            headers.put("Authorization:", "Bearer SAMPLETOKENHERE");
            return headers;
        }

    };
    queue.add(postRequest);
}

【问题讨论】:

    标签: android android-volley wit.ai


    【解决方案1】:

    我发现了我的问题。这是因为我在我的授权中放了一个“:”。我不知道我不需要它。现在可以使用了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-04
      • 1970-01-01
      • 1970-01-01
      • 2014-12-23
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      相关资源
      最近更新 更多