How to stop sending a null value to an API post

Application ID

4A47197B-AE30-FA84-FF56-0071F4010900

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. I am creating a custom function to host a HTTP POST request. The POST request uses the Create Object block to update data at the destination.
  2. The receiving API is set up to erase data if it receives a null data for a property. So this will erase the data in the description property.

image

  1. However, this will not erase the data in the description property.
    image

I want to be able to use the custom function to update any data I want (eg. update the name only) without erasing the data in other properties).

Actual Behavior

The problem I am having is that when I leave a field blank in the custom function, it acts as a null value and erases my data at the API,
image

How should I set it up to reproduce the behavior where my data is not erased?

Hi, @Andreas_Marinopoulos

A field that is sent to the server with the null or empty string property will overwrite data that is already in the table. If you want to avoid overwriting the data in the field, you need to leave the input description blank or do not pass it at it at all in the query.

In my example below, two fields in the Order table will be updated with the passed data: Monosnap.

In this case, I override only the data from one field `name’: Monosnap

Regards,
Marina

Thank you Marina, so the question is how to do that in a custom function that sometimes contains a field and sometimes not. Is this the best way?

image

Yes, @Andreas_Marinopoulos you can use this logic.

Regards,
Marina

Hey @Marina.Kan, it is not working for some reason.

Here’s what I am doing:

  1. I set a variable called description = null on purpose
  2. I check that description = null and provide no value if that is the case.
  3. This still passes the value "description": "" to the server, thus erasing the previous value.

AP id: 4A47197B-AE30-FA84-FF56-0071F4010900
Method Backendless

Hi Andreas,

How about changing the logic where you create a “blank” object that will be passed into the body of your HTTP request. And then checking if the description is not null, then adding the description property to that blank object?

Regards,
Mark

Thanks @mark-piller, that worked. See below: