Reputation: 73
I am getting the below error while calling Watson Visual Recognition API through Java. Any help will be highly appreciated.
VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_20);
service.setApiKey("api_key");
InputStream imagesStream = new FileInputStream("C:\\fruitbowl.jpg");
ClassifyOptions classifyOptions =
new ClassifyOptions.Builder().imagesFile(imagesStream).imagesFilename("fruitbowl.jpg")
.parameters("{\"classifier_ids\": [\"fruits_1462128776\", + \"SatelliteModel_6242312846\"],\"threshold\": 0.6}")
.build();
ClassifiedImages result = service.classify(classifyOptions).execute();
System.out.println(result);
Stacktrace:
SEVERE: POST https://gateway-a.watsonplatform.net/visual-recognition /api/v3/classify?version=2016-05-20&api_key=0b5b96d2428f020c207a9388f2bb1ee840e57c9c, status: 400, error: {
"error": {
"code": 400,
"error_id": "input_error",
"description": "Error parsing 'parameters' JSON. Ensure threshold is a float; owner and classifier-ids are string arrays; url is a string."
}}
Upvotes: 0
Views: 228
Reputation: 497
I think the problem is the +
in the middle of your parameters string. I think it should be:
.parameters("{\"classifier_ids\": [\"fruits_1462128776\", \"SatelliteModel_6242312846\"],\"threshold\": 0.6}")
.build();
Upvotes: 2
Reputation: 4737
The error message refers to classifier-ids
and you have classifier_ids
, so it could be down to a simple typo. Although the documentation also has classifier_ids
in the example - https://www.ibm.com/watson/developercloud/visual-recognition/api/v3/?java#classify_an_image
Upvotes: 0