From 0a188fff77fa19c52e6287c1318d9d7321757e8b Mon Sep 17 00:00:00 2001 From: aboots Date: Thu, 13 May 2021 14:11:46 +0430 Subject: [PATCH] fix: null values in post requests were ignored #538 --- .../main/java/com/androidnetworking/common/ANRequest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android-networking/src/main/java/com/androidnetworking/common/ANRequest.java b/android-networking/src/main/java/com/androidnetworking/common/ANRequest.java index d85b1db8..846d4709 100644 --- a/android-networking/src/main/java/com/androidnetworking/common/ANRequest.java +++ b/android-networking/src/main/java/com/androidnetworking/common/ANRequest.java @@ -19,6 +19,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.util.Log; import android.widget.ImageView; import com.androidnetworking.core.Core; @@ -838,13 +839,16 @@ public RequestBody getRequestBody() { FormBody.Builder builder = new FormBody.Builder(); try { for (HashMap.Entry entry : mBodyParameterMap.entrySet()) { - builder.add(entry.getKey(), entry.getValue()); + if (entry.getKey() != null && entry.getValue() != null) + builder.add(entry.getKey(), entry.getValue()); } for (HashMap.Entry entry : mUrlEncodedFormBodyParameterMap.entrySet()) { - builder.addEncoded(entry.getKey(), entry.getValue()); + if (entry.getKey() != null && entry.getValue() != null) + builder.addEncoded(entry.getKey(), entry.getValue()); } } catch (Exception e) { e.printStackTrace(); + Log.e("Network error", e.getMessage()); } return builder.build(); }