I am trying to deploy this classification model (How to Use the Mental Health Drawing Classification API) to my Android Studio app. However, I received “Request failed with response code: 500” instead.
I am new to both Roboflow and Android Studio, please help me with this. Thank you in advance.
Did it work successfully in the example web app or a request tester like ReqBin?
A 500 error code means that there was an error. I’m not familiar with Java, but you should double-check that the base64 image data is being written properly to the request body.
Taking a look at the classification API docs might be helpful
Hi! Yep, it’s working fine in Roboflow Inference Example. I’ve tried using both base-64 and also valid image url to request body, neither works.
Have you tried passing it through an API testing tool? Since the inference example web app uses the same API that you are using, I think it is likely it might be an implementation issue in Java/Android Studio.
To that end, could you double-check that the request method is properly set to
POST and the image is properly encoded? In my own experience, I’ve had issues with 500 code errors when the request method is not properly set or if the image was not being encoded properly.
If it’s helpful, here’s a Java OkHttp code sample from Postman of a successful request to your model.
OkHttpClient client = new OkHttpClient().newBuilder()
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "*base54*");
Request request = new Request.Builder()
Response response = client.newCall(request).execute();