我正在尝试将 POST 请求从 android 发送到 Django 服务器并尝试执行数据
Android HTTP POST 请求
HttpClient httpclient = sslClient(new DefaultHttpClient());
HttpPost post = new HttpPost("https://www.zzz.com/bulk-loc-add");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("bulkData", params[0]));
Log.v(TAG,"" + params[0]);
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = httpclient.execute(post);
在我的 django 服务器上,我正在写
视图.py
@csrf_exempt
def bulk_loc_add(request):
print request.method
bulk_data = request.POST
print bulk_data
Bulk = request.GET
print Bulk
request.method 当我打印它给我 GET 而不是 POST 并且当我做 request.POST 或 request.GET 它给我空白 QueryDict: {} 我不明白为什么它是空白的我已经看到我的 Eclipse 日志数据是那里。