How to send empty object
See original GitHub issueI am trying to send empty object but retrofit clears out the param with empty or null values. How to make retrofit send empty object or array.
Use case:
I am sending additional_fields
array param as: additional_fields[0]=2
, additional_fields[1]=3
using @Field
etc.
which is working perfectly. But when I am sending additional_fields=[]
with an empty array, retrofit clears out this field and doesn’t send it.
I am doing it in PATCH
call as the user can update its preferences for additional_fields
which can have some value or no value.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to pass empty value to the Object[] variable in java [closed]
To declare institutes empty: public Object[] institutes = new Object[0];. Note that this declares institutes as an empty array, ...
Read more >Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. JSON data has the concept of null and empty arrays...
Read more >How to Check if Object is Empty in JavaScript - Samantha Ming
We can use the built-in Object.keys method to check for an empty object. const empty = {}; Object ...
Read more >provide empty object/array instance #2925 - GitHub
... to return an 'empty object'. at present I had to create a new object/array example: private JsonObject getJsonObjectByName(String name) { if (condition) ......
Read more >42961 (REST API: Cannot pass empty object url encoded data)
When posting using json, empty array is handled correctly. When using querystring, it fails. Please see https://github.com/woocommerce/woocommerce/issues/18249.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@JakeWharton Please help me out with this.
@vipulasri I had the same problem.
You can send empty object or array by using FormBody.Builder. I wrote a sample code. please refer. https://gist.github.com/operando/9e7ebeece0e3c8a637580ee100d77834