794
Views
8
Comments
Solved
Assigning NULL to string variable in a API call
Question

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.

2021-09-06 15-09-53
Dorine Boudry
 
MVP
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

ApiTest.oml
UserImage.jpg
lakshmi Dupati

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. 

UserImage.jpg
Ivan setiawan

i need a proxy to akses the API, so i need to use onBeforeRequestAdvance is there a way to do this ini onBeforeRequestAdvance?

2025-01-09 14-56-57
IQ78

hi, are you consuming or producing?

UserImage.jpg
lakshmi Dupati

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.



2025-01-09 14-56-57
IQ78

In your OnAfterResponse web service put this:

and then you can get the string null in your ResponseText

regards

UserImage.jpg
lakshmi Dupati

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.


2021-09-06 15-09-53
Dorine Boudry
 
MVP
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

ApiTest.oml
UserImage.jpg
lakshmi Dupati

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. 

UserImage.jpg
Ivan setiawan

i need a proxy to akses the API, so i need to use onBeforeRequestAdvance is there a way to do this ini onBeforeRequestAdvance?

2021-09-06 15-09-53
Dorine Boudry
 
MVP

My pleasure,

I would appreciate if you mark my answer as solution

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.