2

We are using Drupal 7.39 and Services 7.x-3.12 .

We are also using organic groups 7.x-2.7 and while creating a node of type attendance (which is a group content). We are not able to assign a group to it.

We are passing the following parameters:

{
  "type": "attendance",    
  "title": "Testing Attendance",  
  "field_attendance_status":{  
  "und":{  
    "tid":3  
  }},  
  "og_group_ref":{  
    "target_id":16  
  }  
}  
0

Try this:

{
  "type": "attendance",    
  "title": "Testing Attendance",  
  "field_attendance_status":{  
  "und":{  
    "tid":3  
  }},  
  "og_group_ref":{
    "und": [
      { "target_id":16 }
    ]  

  }  
}

Either way, you should be able to verify the proper JSON to use by retrieving an existing node that has an og_group_ref.

For example, do a GET request (or just visit in a browser):

?q=[my-api-endpoint]/node/123.json

Then use a tool like jsonlint.com to inspect the JSON.

I'd also like to point out, that the JSON data you send to Services is sometimes dependant on the widget you have selected for the field's form element. See here for more details: https://drupal.stackexchange.com/a/159292/10645

| improve this answer | |
0

I have tried posting group content but didn't work in all field widgets (select, checkbox or auto complete)

I see there exist an issue with that field og_group_ref take a look at that question have an answer with a patch hope to solve the issue.

| improve this answer | |

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.