Fixes AttributeError with api sample test fail

Avoid AttributeError which could be raised with api sample tests
when a string is expected but a non string type is returned
instead. This makes debugging api sample test failures easier as
the expected and actual values are displayed in the error message
rather than an AttributeError exception.

Change-Id: I4d124e4d80779c4431926619f0ca876a513a8462
Merge "Fixes AttributeError with api sample test fail"