1

I'm trying to create a node via services 3 in Drupal 7. The node os created, but when I try to pass the location parameters in, it does not work. If I pass an lid that already exists, it seems to reference that location; if I try to pass a new lid, the information is not registered.

Is there such thing as a location resource for the services module? THis is the JSON string I am using.

{
"title":"test",
"type":"test_type",
"locations":[
      {
         "lid":"4",
         "name":"",
         "street":"",
         "additional":"",
         "city":"",
         "province":"",
         "postal_code":"",
         "country":"us",
         "latitude":"40.663062",
         "longitude":"-73.969760",
         "source":"1",
         "is_primary":"0",
          "locpick":{
            "user_latitude":"40.663061",
            "user_longitude":"-73.969760"
         },
         "province_name":"",
         "country_name":"United States"
      }
   ],
}
4
  • If you print_r the form when you submit it via a regular drupal submission, what does the node object look like? Commented Nov 11, 2011 at 0:03
  • Sorry for my ignorance, where should I insert the statment? I tried creating a small module 'function sitehelper_form_alter(&$form, $form_state, $form_id) { dpr($form); }' it printed out a node like this pastie.org/2848203
    – user379468
    Commented Nov 11, 2011 at 17:14
  • thats the whole node object? looks more like a comment object. Commented Nov 11, 2011 at 22:49
  • ok, let me try that again, here is the entire $form object that is being submitted (the node object is within that I believe). The odd thing is that if I provide a new, distinct lid under locations in the JSON call, it seems to create a location with the correct lid, but it does not seem to grab the latitude or longitude pastie.org/2849875 .... thanks by the way for your help
    – user379468
    Commented Nov 11, 2011 at 23:42

1 Answer 1

1
var node = {
                title: "Sample Location",
                body: { 
                    und: [{
                          value: 'Sample Body'
                          }]
                },
                field_location_type: {
                    und: [{
                          latitude : '37.4861987023',  
                          longitude : '-122.2312',
                          country_name : 'United States',
                          province : 'CA',
                          city: 'My City',
                          postal_code : '12345',
                          name : 'Place Name',
                          }]
                },
                type: 'location',
                language: 'und',
            };

This sets a variable 'node' for Javascript. CCK field is "location_type". All the other parameters are being inserted into the node (city, postal_code,...) , but the Lat/Lon is still not being posted. I suspect that it may be because a node can have many 'locations'. Any help here would be great.

Take a look at the debug log: admin/reports/dblog for the json interaction. You need to turn on Services Debug "Debug mode enabled" located at admin/structure/services/list/api where 'api' is the endpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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