Status Code in method onError of MAS.invoke
search cancel

Status Code in method onError of MAS.invoke

book

Article ID: 267132

calendar_today

Updated On:

Products

CA Mobile API Gateway

Issue/Introduction

I'm building an APP with React Native and MAS SDK 2.3.00 and I was trying to get the request code of the method onError of MAS.Invoke.

The Solution that I had is:

if(Objects.equals(e.getMessage(), "Unauthorized")) {
Log.e("HTTP Status Code", "401");
}

Can you tell me how I can get the "real" status code of MAS.Invoke in method onError?

 

Environment

Release : 4.2

Resolution

To expose the http status code you can use the sample below.

int responseCode = ((TargetApiException)e.getCause()).getResponse().getResponseCode();