I tested last (2.5) version of ModRest class with my REST server. GET, PUT and DELETE methods work fine. I've got a problem with POST. With Chrome's Postman REST client it works. In Modx response I've got: "HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Date: Wed, 29 Jun 2016 20:17:55 GMT Connection: close" .
I tried with 'suppressSuffix' => true and 'addMethodParameter' => true parameters call but no effect.
I reviewed class source code and discovered the probable reason, I suppose (I'm not cURL expert at all) - lack of "if" in post() function
98 public function get($url, $parameters=array(), $headers=array()){
99 return $this->execute($url, 'GET', $parameters, $headers);
100 }
101
108 public function post($url, $parameters=array(), $headers=array()){
109 return $this->execute($url, 'POST', $parameters, $headers);
110 }
111
118 public function put($url, $parameters=array(), $headers=array()){
119 if (!empty($this->config['addMethodParameter'])) {
120 $parameters['_method'] = "PUT";
121 }
122 return $this->execute($url,'PUT',$parameters, $headers);
123 }
124
131 public function delete($url, $parameters=array(), $headers=array()){
132 if (!empty($this->config['addMethodParameter'])) {
133 $parameters['_method'] = "DELETE";
134 }
135 return $this->execute($url,'DELETE', $parameters, $headers);
136 }
or POST usage instead of GET in prepareUrl() function
328 protected function prepareUrl() {
329 $format = $this->getOption('format','json');
330 $suppressSuffix = $this->getOption('suppressSuffix',false);
331 if (!empty($format) && !$suppressSuffix) {
332 $this->url .= '.'.$format;
333 }
334
335 if ($this->method != 'POST' && count($this->requestParameters)){
336 $this->url .= strpos($this->url, '?') ? '&' : '?';
337 $this->url .= $this->_formatQuery($this->requestParameters);
338 }
339
340 $baseUrl = $this->getOption('baseUrl',false);
341 if (!empty($baseUrl)) {
342 if ((!empty($this->url) && $this->url[0] != '/') || substr($baseUrl, -1) != '/') {
343 $this->url = '/' . $this->url;
344 }
345 $this->url = $baseUrl . $this->url;
346 }
347 $this->requestOptions[CURLOPT_URL] = $this->url;
348 return $this->url;
349 }
May be I'm wrong. Any other ideas ?
Regards
Andrzej