web api toDocument

Hello,

I am using a Web API to show a pdf document.

I have one problem, if I use just the function toDocument, it works and returns pdf document, but I need to use an if-else, well, when I use an if-else, doesnt work, it return the id of the document.

Someone knows why doesnt work ?

Good way:

Bad way:

Thank you much.

  Discussion posts and replies are publicly visible