fire frost
fire frost

Reputation: 437

How to make a POST request with ORDS?

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

I created my handler like this :

enter image description here

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 :

enter image description here

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
)

Upvotes: 0

Views: 4149

Answers (1)

Kris Rice
Kris Rice

Reputation: 3410

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.

enter image description here

Upvotes: 1

Related Questions