Hi there,

First of all thanks for this module. It saved me some time.
But I found a bug that was annoying me when I was passing some query information ("The SQL WHERE clause without the word “where”."). So I need it fixed.

Here's my code to make it work:

function _sugarondrupal_rest_serialize_request($url, $method, $params) {
  
  // fguerra
  $data = array(
    'method' => $method,
    'input_type' => 'serialize',
    'response_type' => 'serialize',
    'rest_data' => serialize($params)
  );
  
  // for now is all POST
  $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
  
  $output = drupal_http_request($url, $headers, 'POST', http_build_query($data, '', '&'));
  return unserialize($output->data);
}

and of course that will be likewise to the _sugarondrupal_rest_json_request function.

CommentFileSizeAuthor
#5 sugarondrupal_728756.patch2.09 KBilo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joelbox-Mondial-IT’s picture

Hi it is not clear to me if you mean your code improves this (follows) or if this is the latest improved code. Could you clarify, pls.

taken from 27-3-2010 download:

function _sugarondrupal_rest_serialize_request($url, $method, $params) {
  $query  = 'method='. $method .'&input_type=serialize&response_type=serialize&rest_data=';
  $query .= serialize($params);
  $output = drupal_http_request($url .'?'. $query);
  return unserialize($output->data);
}

ngstigator’s picture

Unless a content-type header is specified, the receiving script may not get the posted content. More info at http://plosquare.blogspot.com/2010/03/solution-for-post-empty-after.html

ilo’s picture

Status: Needs review » Needs work

Actually, there is a TODO in the signature of this function to provide also POST (and DELETE I'd say) according to SugarCRM REST specs, but this is not the way to go, I'd prefer a more worked solution.

ilo’s picture

Title: Bug on drupal_http_request » Make drupal_http_request submit POST requests for the REST service method calls.
Status: Needs work » Fixed

Ok, lets get this one in. I have verified that using SERIALIZE (uppercase and lowercase) I'm unable to perform login, however get_server_info works. Before starting to debug this in the SugarCRM service, I've changed the REST request to always perform POST operations.

Making this change sugarondrupal_set_entry should start working.

Thank you all!

Committed as: http://drupal.org/cvs?commit=468584

Note: Accidentaly I broke the login in previous commits, I'm fixing that in this issue also.
Note: I'm making committs without the whole reviewing proccess because I'm doing a 'lets get a good base code' first. Once I finish this clean up, I promise I'll go through the NR-RBTC-Fixed issue queue process.

ilo’s picture

FileSize
2.09 KB

Sorry, I forgot the committed patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.