Watson Visual Recognition API - 使用byte []接收的无效JSON内容

时间:2017-05-26 12:36:05

标签: java watson visual-recognition

我使用java调用VRA,但是使用byte []时遇到了问题。

        Dim con As SqlConnection
    con = New SqlConnection("Data Source=NBK012\ARPASQL;Initial Catalog=aCommerceDB;Integrated Security=True")
    con.Open()
    Dim cmd As New SqlCommand("INSERT INTO [aOrdini] (ID,NomeProdotto,PrezzoProdotto,Quantità,NumeroOrdine) values(@ID,@NomeProdotto,@PrezzoProdotto,@Quantità,@NumeroOrdine)", con)
    cmd.Parameters.AddWithValue("@ID", GridView1.Rows(0).Cells(1).Text)
    cmd.Parameters.AddWithValue("@NomeProdotto", GridView1.Rows(0).Cells(2).Text)
    cmd.Parameters.AddWithValue("@PrezzoProdotto", GridView1.Rows(0).Cells(3).Text)
    cmd.Parameters.AddWithValue("@Quantità", GridView1.Rows(0).Cells(4).Text)
    cmd.Parameters.AddWithValue("@NumeroOrdine", TextBox9.Text)
    cmd.ExecuteNonQuery()
    con.Close()

这样可以正常工作,但如果我将File()更改为byte [],则会出错 状态:400,

VisualRecognition service = new 
VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_19);
service.setApiKey("{api-key}");
System.out.println("Classify an image");
ClassifyImagesOptions options = 
    new ClassifyImagesOptions.Builder()
        .images(new File(<<anyfile))
        .build();
VisualClassification result = service.classify(options).execute();
System.out.println(result);

我的代码只是将文件从同一图像更改为byte []:

    "description": "Invalid JSON content received. Unable to parse.",
    "error_id": "parameter_error"

有什么想法吗?

0 个答案:

没有答案