Hello, I am attempting to use the Asterisk Manager API to update a configuration file using the UpdateConfig Action. When doing so I am repeatedly getting an error response of “Message: Save of config failed”. Below is a PHP code snippet and if anyone can add some suggestions as to what may be going wrong it would greatly appreciated. On a side note I regularly use the AMI API for other functions so I know that it is working.
// Login
$socket = fsockopen($domain, 5038, $errno, $errstr, 30);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “Username: “.$username.”\r\n”);
fputs($socket, “Secret: “.$secret.”\r\n\r\n”);
$wrets = fread($socket, 8192);
echo $wrets;
// Update Config
fputs($socket, “Action: UpdateConfig\r\n”);
fputs($socket, “Reload: no\r\n”); // No for testing but will be Yes.
fputs($socket, “Srcfilename: pjsip.auth.conf\r\n”);
fputs($socket, “Dstfilename: /tmp/pjsip.test.conf\r\n”); // Just a temp location to see if things work
fputs($socket, “Action-000000: update\r\n”);
fputs($socket, “Cat-000000: 10000-auth\r\n”);
fputs($socket, “Var-000000: password\r\n”);
fputs($socket, “Value-000000: 1234\r\n\r\n”);
$wrets = fread($socket, 8192);
echo $wrets;
// Logoff
fputs($socket, “Action: Logoff\r\n\r\n”);
$wrets = fread($socket, 8192);
fclose($socket);
echo $wrets;