Dear members and seniors
May you all live in peace!
Today, while working with core_course_duplicate_course (web service). I am error given below.
"Notice: Array to string conversion in moodle\bpms\lib\filelib.php on line 3000
invalidparameter Invalid parameter value detected options => Invalid parameter value detected: Only arrays accepted. The bad value is: 'Array'"
My Code is here in below:-
require_once( '../../../lib/zend/Zend/Http/Client/Adapter/Curl.php' );
define( "MOODLE_URL", "http://localhost/bpms/" );
define( "TOKEN_FOR_BUILT_IN_FUNCTIONS", '1e5deac8a0ba32dc542ad7add11df5' );
$params = array(
 'courseid' => 4, 
 'fullname' => 'core_course_duplicate_course test', // New course full name
 'shortname' => 'core_course_duplicate_course', // New course shortname
 'categoryid' => 1, // New course category id
 'visible' => 1, // Make the course visible after duplicating
 'options' => array( array('name'=>'blocks', 'value'=>0)
 , array('name'=>'activities', 'value'=>1)
 , array('name'=>'filters', 'value'=>0)
 , array('name'=>'users', 'value'=>0)
 , array('name'=>'userscompletion', 'value'=>0)
 , array('name'=>'grade_histories', 'value'=>0) 
 ) // Backup options 
);
$function_name = 'core_course_duplicate_course';
$token = TOKEN_FOR_BUILT_IN_FUNCTIONS;
$serverurl = MOODLE_URL . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction=' . $function_name;
$curl = new curl;
$response = $curl->post( $serverurl, $params );
echo $response;
I am using core_course_duplicate_course (Web Service) with stable Moodle 2.3. version. I applied all changes, roles, user token, web service use procedure. All done.
bt why this error occur.
filelib.php code from 2977 to 3003 lines
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this,'formatHeader'));
 // set headers
 if (empty($this->header)){
 $this->setHeader(array(
 'User-Agent: MoodleBot/1.0',
 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'Connection: keep-alive'
 ));
 }
 curl_setopt($curl, CURLOPT_HTTPHEADER, $this->header);
if ($this->debug){
 echo '<h1>Options</h1>';
 var_dump($this->options);
 echo '<h1>Header</h1>';
 var_dump($this->header);
 }
// set options
 foreach($this->options as $name => $val) {
 if (is_string($name)) {
 $name = constant(strtoupper($name));
 }
 curl_setopt($curl, $name, $val);
 }
 return $curl;
 }
Waiting for your positive response.