Closed GitBeagle closed 6 years ago
without looking at you whole code it is difficult to say but in the rest section i dont see where you initialise mqttPass & mqttUser
if these are global variables you either need to update the values in the post code or reload the config to ensure they have the new values in
my assumption should be easy to prove, do the correct values get saved in the json file. you can use the file browser or a reset to confirm this
The variables are global and have valid values read from the userConfig.json file as confirmed by a debug printf. When selecting the Save button on the userConfig.html file the url in the browser address line shows proper arguments with the new values for mqttUser and mqttPass. However, the rest callback always reports zero arguments so the code to store the new values never executes. Somewhere between submitting the url with arguments and the rest callback the arguments seem to disappear. I know the rest callback is executed as I have all the debug messages enabled.
Here are the first 3 lines of code in the rest callback. I can see the output from the printf statement before and after selecting Save. It always shows zero arguments.
void callbackREST(AsyncWebServerRequest *request)
{
if (request->url() == "/rest/userConfig")
{
printf("# args = %d\n", request->args()); // always returns zero arguments
Thank you for taking a look...
John
I'm trying to build on the UserConfigExample using the REST callback. I have been able to create userConfig.json and userConfig.html files. When invoked the userConfig.html file displays the correct data from the json file. When I try to modify the data the url updates with the arguments showing the new data values. However the REST callback does not see these arguments. The callback always prints zero arguments.
I am a complete newB when it comes to web programming and not much better with C++. Given an example I can usually figure out how to tailor it to my needs. This example assumes greater web knowledge than I possess!
I have attempted to attach my userConfig.html file (as a text file) for reference.
Here's my callback code:
userConfig.txt