I am working on API running on PHP. I want to send request in format
http://localhost/crm/api/addCustomer/John/Doe/Address 123/...
It worked, until I hit parameter address containing the / character. It shifted the data saved into the database, quite logically.
So I've done encodeURIComponent before submitting the data from Javacript
address = encodeURIComponent(getVal("address"));
Now I get 404 object not found when I try to call the API.
This is my current URL with encoded data
http://localhost/crm/api/addCustomer/John/Doe/Address%202166%2F62/.....
Here is my .htaccess
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /crm/api
RewriteRule ^getCustomers apihandler.php?action=getCustomers [NC,L,QSA]
RewriteRule ^getCustomer/(.*)$ apihandler.php?action=getCustomer&id=$1 [NC,L,QSA]
RewriteRule ^addCustomer/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+) apihandler.php?action=addCustomer&name=$1&surname=$2&address=$3&country=$4&email=$5&phone=$6 [NC,L,QSA]
How to fix this?
GET
request to create new record.GET
is for getting things, not for creating them. UsePOST
instead. – akond