We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

Pass [] value in Rest CreateAccount JSON

soumyabrata
New Contributor III
New Contributor III

Hi All,

Need to pass telephoneNumber as below if user has phone number else just [] need to be passed.

"phoneNumbers": [
{
"primary": true,
"type": "work",
"value": "+1-xxx-xxx-xxxx"
}
]

Else

"phoneNumbers": []

should be passed.

I am using below statement in my json:

\"phoneNumbers\": \"${if(user?.phonenumber!=null) {[{\"primary\": \"true\",\"type\": \"work\",\"value\":{(user.phonenumber)}}]} else{[]}}\"

But I am getting below error in logs:

com.fasterxml.jackson.core.JsonParseException: Unexpected character ('p' (code 112)): was expecting comma to separate Object entriesat [Source: {"schemas":[

Attached full log here.

Can someone please have a look on it and help if there mistakes in the expression.

 

Regards,

Soumya.

8 REPLIES 8

rushikeshvartak
All-Star
All-Star

Logs missing 

please share full json

\"phoneNumbers\": \"${if(user?.phonenumber!=null && user?.phonenumber!='') {'[{\"primary\": \"true\",\"type\": \"work\",\"value\": \"' + user.phonenumber + '\"}]'} else{'[]'}}\"


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Rajesh-R
Saviynt Employee
Saviynt Employee

@soumyabrata - Please try the following:

\"phoneNumbers\": \"${if(user?.phonenumber!=null) {'[{\"primary\": \"true\",\"type\": \"work\",\"value\": \"' + user.phonenumber + '}]'} else{'[]'}}\"

 


Thanks
Rajesh Ramalingam
Saviynt India

soumyabrata
New Contributor III
New Contributor III

@Rajesh-R @rushikeshvartak 

Still getting the same error in logs. Logs attached here.

 

Can you share json/xml


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Attached here the JSON and data passing from Postman.

Rajesh-R
Saviynt Employee
Saviynt Employee

@soumyabrata  Please try the following:

\"phoneNumbers\": \"${if(user?.phonenumber!=null && user?.phonenumber!='') {'[{\"primary\": \"true\",\"type\": \"work\",\"value\": \"' + user.phonenumber + '\"}]'} else{'[]'}}\"


Thanks
Rajesh Ramalingam
Saviynt India

soumyabrata
New Contributor III
New Contributor III

\"phoneNumbers\": ${if (user?.phonenumber != null && user?.phonenumber != '') { '[{' + '\"value\": \"' + user?.phonenumber + '\"' + '}]' } else {'[]'}}

This is the expression I used and seems working fine.