Hi,
I am writting script to automate the restore process from remote host. To automate restore process, i found one API1[Fileman::restorefiles] function to restore a partial backup.
so that i used that function and made the following URL to call this trough XML API calls.
http://<HOST_NAME>:2082/xml-api/cpanel?user=alwar&cpanel_xmlapi_module=Fileman&cpanel_xmlapi_func=restorefiles&cpanel_xmlapi_apiversion=1
post values :
=================
"arg-0=/home/alwar& arg-1=file-E:/file-backup-3.23.2011_17-01-36_alwar.tar.gz"
And I requested this URL through using CURL in remote windows machine.
I used the following sampele scripts to request this API function.
After i ran this script, i did not get expected result that is mentioned in cPanel API document.
Instead, I got the following result.
could you any one tell me that what mistake i have done in my script ? or Whether this script can not be called through XML API ?
Regards,
Alwar
I am writting script to automate the restore process from remote host. To automate restore process, i found one API1[Fileman::restorefiles] function to restore a partial backup.
so that i used that function and made the following URL to call this trough XML API calls.
http://<HOST_NAME>:2082/xml-api/cpanel?user=alwar&cpanel_xmlapi_module=Fileman&cpanel_xmlapi_func=restorefiles&cpanel_xmlapi_apiversion=1
post values :
=================
"arg-0=/home/alwar& arg-1=file-E:/file-backup-3.23.2011_17-01-36_alwar.tar.gz"
And I requested this URL through using CURL in remote windows machine.
I used the following sampele scripts to request this API function.
Code:
CURLResponse _cURLResponse;
string _url = "http://<HOST_NAME>:2082/xml-api/cpanel?user=alwar&cpanel_xmlapi_module=Fileman&cpanel_xmlapi_func=restorefiles&cpanel_xmlapi_apiversion=1";
strinng _postField = "arg-0=/home/alwar& arg-1=file-E:/file-backup-3.23.2011_17-01-36_alwar.tar.gz";
curl_easy_setopt(curlPtr, CURLOPT_URL, _url.c_str()); /* set the URL */
curl_easy_setopt(curlPtr, CURLOPT_VERBOSE, 0);
curl_easy_setopt(curlPtr, CURLOPT_POSTFIELDS, _postField.c_str()); /* set POST field */
curl_easy_setopt(curlPtr, CURLOPT_WRITEFUNCTION, CPanelAPI::ResponseWriter); /* set CALL_BACK function */
curl_easy_setopt(curlPtr, CURLOPT_WRITEDATA, &_cURLResponse); /* set FOURTH ARG for CALL_BACK function */
curl_easy_perform(curlPtr); /* process given URL */
curl_easy_getinfo(curlPtr, CURLINFO_RESPONSE_CODE, &errNo);
if(errNo == 200 || errNo == 204)
std::cout << _cURLResponse.GetOutputData() << "\n";
else
std::cout << "Error occured when URL was requested "<< errNo << "\n";
Instead, I got the following result.
Code:
<?xml version="1.0" ?>
<cpanelresult>
<module>Fileman</module>
<func>restorefiles</func>
<type>event</type>
<source>internal</source>
<apiversion>1</apiversion>
<data>
<result></result>
</data>
<event>
<result>1</result>
</event>
</cpanelresult>
Regards,
Alwar
Last edited: