Skip null form values for Java native request builder (#15036)

This commit is contained in:
RInverid
2023-03-29 04:55:28 +02:00
committed by GitHub
parent 1cdcaeb1b9
commit 36332331e4
7 changed files with 141 additions and 47 deletions

View File

@@ -157,9 +157,15 @@ public class FormApi {
localVarRequestBuilder.header("Accept", "text/plain");
List<NameValuePair> formValues = new ArrayList<>();
formValues.add(new BasicNameValuePair("integer_form", integerForm.toString()));
formValues.add(new BasicNameValuePair("boolean_form", booleanForm.toString()));
formValues.add(new BasicNameValuePair("string_form", stringForm.toString()));
if (integerForm != null) {
formValues.add(new BasicNameValuePair("integer_form", integerForm.toString()));
}
if (booleanForm != null) {
formValues.add(new BasicNameValuePair("boolean_form", booleanForm.toString()));
}
if (stringForm != null) {
formValues.add(new BasicNameValuePair("string_form", stringForm.toString()));
}
HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8);
ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream();
try {