How to make a POST request with ORDS?

我们两清 提交于 2019-12-24 23:19:22

问题


I want to insert a new item with a POST request in ORDS application express.

I created my handler like this :

Then with android studio, I use volley to create a JSONObject (& the request at the same time) :

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();

I also tried this request with postman :

As you can see, I get a error 500 and I can't find the problem. If I do the query in SQL command, it works fine :

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

What should I do to make my post request work?

edit

here's the table definition :

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:


My guess of the table definition.

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.

Never used Volley but here's basic cUrl

## 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"
}'

The definition of the rest.



来源:https://stackoverflow.com/questions/50455756/how-to-make-a-post-request-with-ords

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!