I have added field of type Geofield that failed to save through services despite working well with node and user modules

It returns that error 400 : Invalid field_geoloc value given I am using the same field structure for node and user.

I did some debugging and found that the error comes from file commerce_services.module line 1406 that piece of code

if (count(array_diff_key($value, $field_info['columns'])) > 0) { return services_error(t('Invalid @field value given', array('@field' => $field_name)), 400); } here is the field structure

"field_geoloc": {
    "und": [
            "geom": {
                "lat": "22",
                "lon": "22"

Please help me fix it or guide to fix it. Thanks in advance

  • I don't think a value of 22 is valid for either coordinate. This answer may be useful: drupal.stackexchange.com/a/146546/10645 - remember the values you send up are dependant on the form widget you have selected for the field in Drupal. I'd recommend adding this line above line 1406: watchdog('commerce_services', '<pre>' . print_r($field_info['columns'], true) . '</pre>'); - that way you can see what it is expecting. – tyler.frankenstein Oct 22 '15 at 13:17
  • that values are accepted for user and node modules, I think it needs complete field data unlike node and user modules does here is the output of the watchdog at commerce services pastebin.com/rkfpyKLn – Mohammed Gomma Oct 23 '15 at 7:40
  • Have you checked the issue queue? – nvahalik Oct 27 '15 at 12:04
  • I have checked and created an issue – Mohammed Gomma Oct 28 '15 at 8:39

The answer is to send computed values via the geofield module api itself by Implementing the hook_request_parsed_alter like:

function my_module_request_parsed_alter(&$data, $controller) {
switch ($controller['callback']) {
case 'commerce_services_product_create':
case 'commerce_services_product_update':

  if (isset($data['field_geoloc'])) {
    $data["field_geoloc"] = geofield_compute_values($data['field_geoloc']['und'][0]['geom']);

But I still wonder why not working by default as node create request

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.