fix the NPE problem when REST client with SAM