【发布时间】:2016-08-05 05:31:11
【问题描述】:
我们在客户端使用 ionic 框架 并在服务器端使用 rest webservices 开发移动应用程序。从客户端,我能够成功连接到 mfp 服务器。 现在我正在尝试将我的 Web 服务服务器与 mfp 服务器连接以发送 pushnotifications 。但我收到 405 错误。这是我编写的代码
URLConnection connection = new URL("http://localhost:9441/mfp/api/az/v1/token").openConnection();
connection.setDoOutput(true); // Triggers POST.
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("grant_type", "client_credentials");
connection.setRequestProperty("scope", "messages.write");
connection.setRequestProperty("scope", "push.application.com.ionicframework.example854621");
InputStream response = connection.getInputStream();
System.out.println("response"+response);
这是我收到的回复
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 405 for URL: http://180.151.63.116:9441/mfp/api/az/v1/token
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at com.sai.laps.webservice.server.authentication.mfp.main(mfp.java:24)
我哪里错了?如何将我的 REST Web 服务服务器与 MFP 服务器连接?
任何帮助将不胜感激!
【问题讨论】:
标签: java rest ionic-framework ibm-mobilefirst