Hello …
When I try Registration using normal way the E-mail send , But when i try Registration by API Activation E-mail not send .
Any idea ,
Thanx in advance …
Check HTTP response and make sure your action is successful.
action is successful add the user , and The user is apear in database but not activated
Normal registration and REST API uses the same class/code, you better enable Debug and check for PHP errors in the log file.
i got this error what is mean ?[2022-06-18T14:27:34.721097+00:00] log.DEBUG: Slim Application Error Type: Doctrine\DBAL\Exception\NotNullConstraintViolationException Code: 1364 Message: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1364 Field ‘user_email’ doesn’t have a default value File:
That means you did not provide the ‘user_email’ field when you register via API and therefore the record cannot be inserted successfully since the field is a NOT NULL field without a default value.
my Registration page content this three field
user_email
password
usernamehere how I call the Registration API using postman:
methoud : Post → https://www.mysite.com/myapp/api/register?user_email=my_email@gmail.com&password=123&username=my_userI got this response
{
"statusCode": 0,
"error": {
"class": "text-danger",
"type": "Error",
"description": "An internal error has occurred while processing your request."
}
}
and the user failed to add in database and for sure Activation E-mail not send
in error log I got that error :[2022-06-18T14:27:34.721097+00:00] log.DEBUG: Slim Application Error Type: Doctrine\DBAL\Exception\NotNullConstraintViolationException Code: 1364 Message: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1364 Field ‘user_email’ doesn’t have a default value
Now i have try my project on localhost
I call same API Method: Post → http://localhost/myapp/api/register?user_email=my_email@gmail.com&password=123&username=my_useri got this response
{“success”:true,“users”:{“id”:“1”},“version”:“18.12.0”}I think i have an error on my server config ,
But i can’t figure out what it could be
You need to post the form data (i.e. put the data in the body of the request as “form-data” or “x-www-form-urlencoded”), not via URL parameters, read API Actions.
Wonderful I got Success response from PostMan using body form-data :
10.66.110.30fd42: 42: 42: : 7036{
"success": true,
"users": {
"file_config": {
"type": "application/x-zip-compressed",
"url": "https://www.mysite.com/myapp/api/file/users/GfOwYnPaChv6qFMPcJqwmF8ndmqoBzPdIwF1LNoqgqfWz1pS3jJOKo0BiF4M_msYR7dHvAPRJKzdVmk9CRn31MgUgWt3TvlzVB--9vsHt60JxDhecRcWdw..",
"name": "84.zip"
},
"start_date": "2022-06-19",
"user_status": 0,
"user_exp": 1
},
"version": "18.11.0"
}
But now we return to the main Point I still cannot receive the Activation Email via the API URL
There is still no “user_email” in your user data. Make sure you have provided it when you register via API.arbei wrote:
Check HTTP response > and make sure your action is successful.
You may check the data you sent in the Network → Request panel in Chrome.
Yah That becoze i use Server side rowInserted() code but i have try to remove it and use the orgenal Class
still not send the activaetion email only it’s send by normal way
here the PostMan response from orgenal class
{
"success": true,
"users": {
"user_email": "xxx@gmail.com",
"password": "123",
"username": "sss",
"id": "89"
},
"version": "18.11.0"
}
but i still not reseving the email
You may learn to debug by, for example, using the Email_Sending server event, e.g.
Log(var_export($mail, true));
Log(var_export($args, true));
Log($email->send());
Run your code to call the API, then check the log file, see if the email properties are correct.
[2022-06-19T08:48:48.814320+00:00] log.DEBUG: Message body empty Empty Message body , Only via API
If the Email_Sending event is not fired, that means the record is not considered to be added successfully. However, since you can receive the success JSON result and your Row_Inserted server event is called, that means the record is added successfully. Make sure you have enabled debug as said above during development. Check the PHP error message in the log file. The more proper way to debug is to open your PHP debugger and step through the code after addRow() in the Register class. It might be time to learn better PHP debugging, you may google “php xdebug” to find more info.
After long time , i found the problem was with html Path for the email body contant so from src/config.php file i have change
from"EMAIL_TEMPLATE_PATH" => “html”, // Template pathto
“EMAIL_TEMPLATE_PATH” => “…/html”, // Template pathJust fix the html Path for API Action
Thanx
i think it must be tow type of TEMPLATE HTML PATH , eg:for page action
“EMAIL_TEMPLATE_PATH” => “html”, // Template pathand for API Action , eg :
“EMAIL_TEMPLATE_PATH_API” => “…/html”, // Template path