代码之家  ›  专栏  ›  技术社区  ›  fire frost

如何使用ORDS发出POST请求?

  •  0
  • fire frost  · 技术社区  · 8 年前

    我想在ORDS Application Express中插入一个带有Post请求的新项目。

    我创建了这样的处理程序:

    enter image description here

    然后使用android studio,我使用volley创建jsonObject(同时创建请求):

    JSONObject jsonBody = new JSONObject();
    jsonBody.put("name", name);
    jsonBody.put("genres", genres);
    jsonBody.put("season", season);
    jsonBody.put("episodes", nb_episodes);
    jsonBody.put("rating", "0");
    final String requestBody = jsonBody.toString();
    

    我还向邮递员尝试了这个请求:

    enter image description here

    如你所见,我得到一个错误500,我找不到问题。如果我在SQL命令中执行查询,它将正常工作:

    Insert into android_anime (name, genres, season, nb_episode, rating)
    Values ('anime5', 'G6', 2, 24, 5)
    

    我该怎么做才能使我的职位申请生效?

    编辑

    表定义如下:

    CREATE TABLE  "ANDROID_ANIME" 
    (   "ID" NUMBER, 
    "NAME" VARCHAR2(30), 
    "GENRES" VARCHAR2(30), 
    "SEASON" NUMBER, 
    "NB_EPISODE" NUMBER, 
    "RATING" NUMBER, 
     CONSTRAINT "ANDROID_ANIME_PK" PRIMARY KEY ("ID")
    USING INDEX  ENABLE
    )
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   Kris Rice    8 年前

    我对表格定义的猜测。

    SQL> create table android_anime(
      2  name varchar2(200),
      3  genres varchar2(200),
      4  season number,
      5  nb_episode number,
      6* rating number);
    
    Table ANDROID_ANIME created.
    

    从来没有用过凌空射门,但这里有基本的曲度

    ## anime-lowercase
    curl -X "POST" "https://apex.oracle.com/pls/apex/dbtools/test/postAnime" \
         -H 'Content-Type: application/json' \
         -d $'{
      "genres": "G6",
      "season": "1",
      "name": "anime-99",
      "nb_episode": "1",
      "rating": "1"
    }'
    

    其余部分的定义。

    enter image description here