faithoflifedev / google_vision_workspace

Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
MIT License
20 stars 8 forks source link

DioException [bad response]: This exception was thrown because the response has a status code of 400 and RequestOptions.validateStatus was configured to throw for this status code. #20

Closed CanArslanDev closed 5 months ago

CanArslanDev commented 5 months ago

Hello, I have opened this issue before in this issue, unfortunately I could not find a solution so I formatted my computer and it was solved. Now I encountered this problem again and I cannot solve it. I checked the api key, although it works on my other windows and mac devices, it does not work on a specific windows computer. What's different is that it was broken yesterday when I just turned off and turned on the computer while it was working. When I tested all the other APIs, I saw that they worked without any problems, so I do not think there is a problem with the internet. But I couldn't find the reason for this problem.

This code gives an error, I am 100% sure that the credentials are correct

final googleVision = await vision.GoogleVision.withJwt(jwtFromAsset)

Logs

I/flutter ( 6977): DioException [bad response]: This exception was thrown because the response has a status code of 400 and RequestOptions.validateStatus was configured to throw for this status code.
I/flutter ( 6977): The status code of 400 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
I/flutter ( 6977): Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
I/flutter ( 6977): In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.
I/Camera  ( 6977): refreshPreviewCaptureSession

Version

google_vision: 1.2.1

OS: Windows 11

faithoflifedev commented 5 months ago

Hi @CanArslanDev,

I'm not sure you're aware, but as of about 5 months ago I published a Flutter specific Google Vision Package. It might be worth your while to migrate to this package. Also, the latest releases of both the Dart and Flutter packages also support the use of an API key in place of the JSON credentials file, which might make things a bit easier for you.

In terms of the issue you mentioned above, I don't have a Windows 11 environment to test with and you haven't really provided enough information for me to recreate the issue. Maybe try switching to the Flutter widget and see if the issue is resolved.