Get the data for Android POST in the django server… here is a solution to the problem.
Get the data for Android POST in the django server
I’m trying to send a POST request from android to a Django server and trying to execute data
Android HTTP POST request
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);
On my django server I’m writing
View .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 When I print it gives me GET instead of POST when I do request. POST or request. GET it gives me blank QueryDict: {} I don’t understand why it’s blank I see my eclipse log data there.
Solution
The URL you request does not end with a slash, and Django may redirect to the version with the slash and lose POST data in the process. You should request “https://www.zzz.com/bulk-loc-add/"
.