使用java向自定义视觉服务预测API提交请求 [英] Submitting a request to the custom vision service prediction API using java

查看:98
本文介绍了使用java向自定义视觉服务预测API提交请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将代码作为c#中的示例示例,并尝试将其切换为java。但是,java应用程序正在给出  http响应代码为400.如果我运行c#应用程序,则正确到达预测API,因此我知道
值正确。 


可以找到示例c#代码这里  https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/use-prediction-api


我提交的java代码在这里:

 HttpURLConnection connection =(HttpURLConnection)url.openConnection(); 
connection.setDoOutput(true);

connection.setRequestMethod(" GET");
connection.setRequestProperty(" Prediction-Key",predictionKey);
connection.setRequestProperty(" Content-Type"," application / octet-stream");

DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.write(data.getData());

我不确定上述java请求有什么问题。感谢任何帮助。

解决方案

您好,这个问题更适合认知服务论坛:  https://social.msdn.microsoft.com/Forums/en-US/home?forum = AzureCognitiveService

I have take the code that is given as a sample example that is in c# and attempted to switch it to java. However, the java application is giving  http response code of 400. If i run the c# application the prediction API is reached correctly so i know the values are correct. 

The sample c# code can be found here https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/use-prediction-api

my code for the java submission is here:

                        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                        connection.setDoOutput(true);

                        connection.setRequestMethod("GET");
                        connection.setRequestProperty("Prediction-Key", predictionKey);
                        connection.setRequestProperty("Content-Type", "application/octet-stream");

                        DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
                        outputStream.write(data.getData());

I am not sure what is wrong with the above java request. Any help is appreciated, thanks.

解决方案

Hi, this question would be better suited in the Cognitive Services forum : https://social.msdn.microsoft.com/Forums/en-US/home?forum=AzureCognitiveService


这篇关于使用java向自定义视觉服务预测API提交请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆