【问题标题】:POST method not workingPOST方法不起作用
【发布时间】:2023-04-04 23:17:01
【问题描述】:

我正在开发一个 android 应用程序,它通过 RESTful 服务访问我在云中的 Oracle 数据库,Oracle APEX 提供了用于创建 REST 服务的接口,在客户端我能够通过 JAVA HttpClient API 和响应调用 GET 请求在 JSON 格式中很好。问题是当调用 POST 请求时我没有得到适当的响应。我按照文档的指示做了所有事情, (还定义了出站参数) 请看看这个图片广告告诉我是否做错了什么 http://i58.tinypic.com/2gt5bb5.png

客户端的代码是这样的:

HttpPost post = new HttpPost(url);
JSONObject json = new JSONObject();
json.put("MNUM", "234564");
StringEntity se = new StringEntity( json.toString());
post.setEntity(se);
HttpResponse response = httpClient.execute(post);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity); // this function converts response to string

源码中的PL/SQL是:

DECLARE
id USER_INFO.m_number%type; //user_info is a table and m_number is its primary key (which i am trying to post from my app)
BEGIN
INSERT into USER_INFO(m_number)
values(:MNUM)
returning m_number into id;
:status := 201;
:location := id;
commit;
END;

任何人都可以告诉我为什么我无法在这一切之后发布,任何帮助将不胜感激,我从几天开始就被困在这部分。 我收到的错误是服务不可用。

【问题讨论】:

  • 你检查过你的 RESTful 服务是否支持 POST 请求吗?
  • 是的,请看链接,这是创建POST RESTful服务的接口
  • 必需的安全访问 - 是的,也许这会有所不同
  • 那不是问题,我已经检查过了..

标签: java android oracle11g oracle-apex


【解决方案1】:

使用 Postman 应用 (chrome webstore) 测试您的 API 调用并查看它们是否有效。如果这不能帮助您解决问题,请粘贴输入和输出。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-23
    • 2015-03-19
    • 2012-05-31
    • 2019-01-07
    • 2018-01-28
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多