Avoid fatal errors in api

PHP Fatal error:  Call to a member function getPrefixedText() on a non-object

Change-Id: I1e7fe7df9e3e81fbd4c687abaae6ca027f55f0c7