Question

Issue with setting Null Type at JSON request

Hi All,

I am consuming a Service through Connect-REST for which i have to sent value for different types of properties( Integer, Text, Boolean) which is mandatory. if i don't have value i am supposed to null with out quotes but when i am forming my request the null is going with quotes which is not accepted by service.

When i checked in JASON standard, there is some type call null to handle this. please find the below link and details for this

https://stackoverflow.com/questions/9619852/what-is-the-convention-in-json-for-empty-vs-null/9623521

"Strings, Booleans and integers do not have an 'empty' form, so there it is okay to usenull values. "JSON has a special value called null which can be set on any type of data including arrays, objects, number and boolean types."

Is it possible to achieve this in Pega? please help us on this, this is impacting our development activities. We are using Pega 7.1.7 version.

Comments

Keep up to date on this post and subscribe to comments

October 15, 2018 - 4:45am

Ideally, you can send null in the JSON request. I have used multiple services set up in PEGA which take null parameters. 

Ex: 

......

"propname": null,

.....

 

Can you check if this is the format you used ? if yes, there is some other reason for the call to fail. Can you check the logs and the stack trace to debug it further.

October 15, 2018 - 10:11am

Hi Soumya,

        I am trying to set my request param using the following syntax @if(@(Pega-RULES:Default).PropertyExists(.TextProperty), ".TextProperty", "null"). both LHS and RHS properties are Text Properties. my concern is values going in the request not going as follows "TextProperty": null. It is going as "TextProperty": "null". 

October 15, 2018 - 10:36am
Response to IMRANBEIG

Hi, This is expected behavior of @IF function which returns string value only. It should be explicitly set as null, not through IF function.

October 15, 2018 - 2:25pm
Response to PraveenKVM_Incessant

Praveen, i don't want to set null always. Service is expecting null when there is no value for particular property. if assign the property directly its going as "TextProperty":" " which will not work out. If we set null value directly also it is going as follows "TextProperty":" ".

October 17, 2018 - 6:16am

Hi,

If property has null then dont send that value if it is non mandatory .

October 17, 2018 - 9:48am
Response to Gayatri

Hi Gayathri,

     Properties are mandatory and Service is expecting null value without quots if there is no values passed to those properties.

October 22, 2018 - 10:09am

Hi @Vidyaranjan / @KipJackson_GCS,

    I have not got my above mentioned query resolved, is it possible for you guys to help me on this please? Please do the needful.

 

November 6, 2018 - 1:55pm

Hi Moderator,

    Still my query not resolved with respect to this post. Please help me on this.

February 18, 2019 - 9:09am
Response to IMRANBEIG

Hi , Did you get a solution for the above problem ?

Thanks

December 10, 2019 - 3:02pm

Any solution for this issue?

December 11, 2019 - 3:36am
Response to RISHAVRAJ

Hi @RISHAVRAJ

Thank you for posting your query in the PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write Post button here. Once created, please reply here with the URL of the new post.

You may also refer this discussion link as a reference in the new thread.

Vidyaranjan | Community Moderator | Pegasystems Inc.