Assigning NULL to string variable in a API call

We are consuming REST API from 3rd party.

It is expecting null be send if variable value empty like below.

"attribute_for_delete":null

1. Tried "Send Default Value" = Yes.

2. Tried not to assign anything to the variable if the value is empty. Thought this would assign default value to the variable.

3. Tried to assign NullTextIdentifier

But nothing seems to be working.

hi, are you consuming or producing?

brrr wrote:

hi, are you consuming or producing?


Consuming the REST API.

This is sample Jason request with Email.

I want to send null to email as my user has no email address.These values are coming from UI.



In your OnAfterResponse web service put this:

and then you can get the string null in your ResponseText

regards

Solution

Hi lakshmi,

you could massage your request JSON inside the OnBeforeRequest, replacing the unwanted bits by null.

See attached OML.

when some value is not entered, I replace it with "null" in my action logic.


and then inside the OnBeforeRequest, I simply replace all "null" by null.



So, it doesn't really have to be value "null", that's just an example, whatever string you choose to mean <should be replaced by null before we send the request> is fine.

Results :


I think something similar will do the trick for you,

Dorine

Solution

Dorine Boudry wrote:

Hi lakshmi,

you could massage your request JSON inside the OnBeforeRequest, replacing the unwanted bits by null.

See attached OML.

when some value is not entered, I replace it with "null" in my action logic.


and then inside the OnBeforeRequest, I simply replace all "null" by null.



So, it doesn't really have to be value "null", that's just an example, whatever string you choose to mean <should be replaced by null before we send the request> is fine.

Results :


I think something similar will do the trick for you,

Dorine


Thanks Dorine Boudry.


I tried replacing request test with null in OnBeforeRequest.

Its working amazing.

Thanks for your time in explaining. Much appreciated. 

brrr wrote:

In your OnAfterResponse web service put this:

and then you can get the string null in your ResponseText

regards

Thanks brr.

This gave the idea where to change the text. You guys are amazing and quick.


My pleasure,

I would appreciate if you mark my answer as solution