How to do Add/Edit with REST API?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
milver.silva
User
Posts: 18

How to do Add/Edit with REST API?

Post by milver.silva »

Hello,
I am studying the RestAPI part with PHPMaker.
I am creating a CRUD but I have problems with the add and edit actions as shown below:

TABLE: CADUSU (CODUSU {key}, NOMCOM, ENDEMA)

OK -> List With URL Rewrite GET: /api/list/cadusu

OK -> View With URL Rewrite GET: /api/view/cadusu/milver.silva

OK -> Delete With URL Rewrite POST: /api/delete/cadusu/milver.silva

ERROR -> Edit Without URL Rewrite POST: /api/?action=edit&object=cadusu&CODUSU=milver.silva&NOMCOM=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")

ERROR -> Edit With URL Rewrite POST: /api/edit/cadusu/milver.silva/NOMCOM=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")

ERROR -> Add Without URL Rewrite POST: /api/?action=add&object=cadusu&CODUSU=MARCELA.SILVA&NOMCOM=MARCELA&ENDEMA=marcela@outlook.com (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)

ERROR -> Add With URL Rewrite POST: /api/add/cadusu/CODUSU=MARCELA.SILVA&NOMCOM=MARCELA&ENDEMA=marcela@outlook.com (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)

Note: Project without login.


arbei
User
Posts: 9401

Post by arbei »

milver.silva wrote:
TABLE: CADUSU (CODUSU {key}, NOMCOM, ENDEMA)

You may try:

  • object=CADUSU vs. object=cadusu (case sensitivity)
  • urlencode("marcela@outlook.com")
  • make sure the value matches that in database (CODUSU=milver.silva vs. CODUSU=MARCELA.SILVA)
  • check the field variable name, see the topic Tools > Database, Table and Field variable names in the help file

milver.silva
User
Posts: 18

Post by milver.silva »

Don't work :(

............::::::::ADD::::::::............
ERROR -> Add With URL Rewrite POST: /api/add/cadusu/CODUSU=MARCELA.SILVA&NOMCOM=MARCELA&ENDEMA="marcela@outlook.com" (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)
ERROR -> Add With URL Rewrite POST: /api/add/cadusu/CODUSU=MARCELA.SILVA&NOMCOM=MARCELA&ENDEMA='marcela@outlook.com' (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)
ERROR -> Add With URL Rewrite POST: /api/add/cadusu/codusu=MARCELA.SILVA&nocom=MARCELA&endema="marcela@outlook.com" (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)
ERROR -> Add With URL Rewrite POST: /api/add/cadusu/codusu=MARCELA.SILVA&nocom=MARCELA&endema='marcela@outlook.com' (Notice: Undefined index: CODUSU in \classes\cadusu_add.php on line 1050)

............::::::::EDIT::::::::............
ERROR -> Edit With URL Rewrite POST: /api/edit/cadusu/milver.silva/nomcom=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")
ERROR -> Edit With URL Rewrite POST: /api/edit/CADUSU/milver.silva/NOMCOM=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")
ERROR -> Edit With URL Rewrite POST: /api/edit/CADUSU/milver.silva/nomcom=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")
ERROR -> Edit With URL Rewrite POST: /api/edit/cadusu/milver.silva/NOMCOM=teste ("success": false,"failureMessage": "No records found","version":"16.0.1")


arbei
User
Posts: 9401

Post by arbei »

milver.silva wrote:
Notice: Undefined index: CODUSU

"CODUSU" does not exist. Are you sure it is correct? You better check the spelling and the letter case and...

arbei wrote:
check the field variable name, see the topic Tools > Database, Table and Field variable names in the help file


milver.silva
User
Posts: 18

Post by milver.silva »

I will try with demo project


Post Reply