Gursimrat
11 years agoLeader
Freemarker If/else not working, strange.
I am not able to handle the exception here Below is the response XML which is giving the error: <response status="error">
<error code="503">
<message>An object in the path is null.</message>
...
- 11 years ago
I'm a little late to the party, but thought I'd share a work-around I've used in the past for this situation. In the code below, I check first to see whether the user has an avatar. I do this by seeing if the object returned via the REST API is not null. If it's not null (there's an image), then I make an additional REST API call to get the avatar in the desired size.
<#attempt> <#assign avatarObj = restadmin("/users/id/${user.id?c}/profiles/avatar").image /> <#if !((avatarObj.@null[0])?? && avatarObj.@null=="true") > <#assign avatar = restadmin("/users/id/${user.id?c}/profiles/avatar/size/profile").image /> </#if> <#recover> </#attempt> ${avatar.url!""}
I hope this helps!