3

I am trying to Create Services to Create Node Type Discussion in a Group using Services Module, but getting the error : 401 Unauthorized : Missing required argument node

In the Header I have given:

Content-type:application/json

x-csrf-token:token value

session-name:session name value

In the Body I have given :

{
"og_group_ref": {"und": [{"target_id": "3897"}]},

"title": "Title of discussion",

"field_description": {"und": [{"value": "test description"}]},

"type": "discussion",

}

Can anyone please tell me why I am getting this error ?

Screen Shot

  • possible same question that may help you drupal.stackexchange.com/questions/50559/… – WaQaR Ali Oct 6 '15 at 11:15
  • Try this: {"node":{"og_group_ref": {"und": [{"target_id": "3897"}]},"title": "Title of discussion","field_description": {"und": [{"value": "test description"}]},"type": "discussion"}} – Huelfe Oct 6 '15 at 11:19
  • Didn't worked. I am getting this error : 500 Internal Server Error : An error occurred(0): Unknown data property field_group_privacy. – Malik Oct 7 '15 at 6:47
0

You put comma on last parameter "type": "discussion", that doesn't required at the end. javascript, jquery, json doesn't allow comma at end of array. It returns invalid argument.

  • Thanks for you help but now I am getting > 500 internal Server Error : An error occurred(0): Unknown data property field_group_privacy. – Malik Oct 6 '15 at 11:37
  • you didn't add field_group_privacy field here? Are you missing or parameter is wrong i am not getting? – vgoradiya Oct 6 '15 at 11:41
  • Do I need to add this on body ? "field_group_privacy":{"und":[{"value": "0"}]} – Malik Oct 6 '15 at 11:45
  • first of all you need to call get node service where actually you get what properties you need to pass in body. Just call drupal.org/endpoint/node/123.json and click on GET in poster. – vgoradiya Oct 6 '15 at 11:50
  • Yes, I checked it but there no property with the name of field_group_privacy ? This field look like a field of Group but I am creating Discussion within a Group – Malik Oct 6 '15 at 12:03
0

Try wrapping your data like so:

{
  node: {
    type: 'discussion',
    /* ... */
  }
}
  • Didn't worked. I am getting this error : 500 Internal Server Error : An error occurred(0): Unknown data property field_group_privacy. – Malik Oct 7 '15 at 6:32
  • Usually a 500 means you have a syntax error somewhere up in PHP in Drupal. From the error, it looks like someone is trying to access field_group_privacy on an entity without verifying it isset() first. – tyler.frankenstein Oct 7 '15 at 14:07

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.