Android Question Get main error text in Httpjob

darabon

Active Member
I try to send data to a special endpoint URL in B4a
For error 403 or 404, I sent data to the client and in Postman, I can see it
But in B4a, only receive error "ResponseError: unknown error, status code: 401"
I need to main error
For example, when user was not found, I sent 403 with the error "User not found"
That "User not found' is necessary for my app
Tip: I used ErrorMessage but there is not main error
Tip: My main error is {"status":false,"error":"not found user"}
Thanks
 

aeric

Expert
Licensed User
Longtime User
I try to send data to a special endpoint URL in B4a
For error 403 or 404, I sent data to the client and in Postman, I can see it
But in B4a, only receive error "ResponseError: unknown error, status code: 401"
I need to main error
For example, when user was not found, I sent 403 with the error "User not found"
That "User not found' is necessary for my app
Tip: I used ErrorMessage but there is not main error
Tip: My main error is {"status":false,"error":"not found user"}
Thanks
Do you get any value with job.GetString?
 
Upvote 0

darabon

Active Member
The response payload is not downloaded is the status code is not 2xx.

You can get the status code from Job.Response. In most cases it should be enough.
You can download the response yourself with Job.Response.GetAsynchronously
I use OkHttp library not a source
That is not enough for me Erel
I remember once I could get that data but forgot it
Can I use GetAsynchronously with reflaction?
That is important please give me more help
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

darabon

Active Member
You mean OkHttpUtils2. Good.

Ok.

OkHttpUtils2 never downloaded the payload on non-success codes.

No. You can use it directly.
So I have to use Httputil source to solve my problem?
I want to add an error in the header and receive in app but that is no good solution
 
Upvote 0
Top