json layer now returns appropriate json error response rather then html response