I have created a server api/testAuth which uses session authentication. For both the comment and node resources, create and retrieve are enabled. Server is set to return all responses in JSON format.

My problem is that I am unable to post/create a comment. Request yields 406 error "Comment field is required (or a driven property change otherwise)." I am using the JSON syntax from Services Sandbox tests http://drupal.org/node/1447020 so I hope but am not certain my request contains the needed elements. Here's an example; I have replaced my session cookie and user/pass with placeholders for security:

curl -v -u <user:pass> "http://dev.bouldermountainbike.org/api/testAuth/comment" --data @testComment.json --header "Content-Type:application/json" -b <sessionCookie>

* About to connect() to dev.bouldermountainbike.org port 80
*   Trying 166.78.2.191... connected
* Connected to dev.bouldermountainbike.org (166.78.2.191) port 80
* Server auth using Basic with user '****'
> POST /api/testAuth/comment HTTP/1.1
> Authorization: Basic Ym1hYWRtaW46Ymlnd2hlZWxz
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: dev.bouldermountainbike.org
> Accept: */*
> Cookie: <sessionCookie>
> Content-Type:application/json
> Content-Length: 237
> 
> {  "nid":175,  "subject":"Comment submitted via JSON REST",  "comment_body":{    "und":[      {      "value":"this test comment will get posted to the Lower Bitterbrush trail (nid=175) with appropriate user and timestamp"      }    ]  }}
< HTTP/1.0 406 Not Acceptable: Comment field is required (or a driven property change otherwise).
< Date: Thu, 28 Feb 2013 17:01:51 GMT
< Server: Apache/2.2.22 (Ubuntu)
< X-Powered-By: PHP/5.3.10-1ubuntu3.4
< Expires: Sun, 19 Nov 1978 05:00:00 GMT
< Last-Modified: Thu, 28 Feb 2013 17:01:51 GMT
< Cache-Control: store, no-cache, must-revalidate
< Cache-Control: post-check=0, pre-check=0
< Vary: Accept
< Content-Length: 70
< Connection: close
< Content-Type: application/json
Closing connection #0
["Comment field is required (or a driven property change otherwise)."]

Comment resource works great for retrieve:

curl -u <user:pass> "http://dev.bouldermountainbike.org/api/testAuth/comment/405" 

{"cid":"405","pid":"0","nid":"405","uid":"350","subject":"Rode on 3/2.  A couple","comment":"Rode on 3/2.  A couple sections of mud that needed to be walked, otherwise dry and super fun!","hostname":"24.9.60.238","timestamp":"1299294812","status":"0","format":"1","thread":"07/","name":"joybuhl","mail":"","homepage":""}

I know the cookie is valid because I can successfully create a node:

 curl -v -u <user:pass> "http://dev.bouldermountainbike.org/api/testAuth/node" --data @testNode.json --header "Content-Type:application/json" -b <sessionCookie>

* About to connect() to dev.bouldermountainbike.org port 80
*   Trying 166.78.2.191... connected
* Connected to dev.bouldermountainbike.org (166.78.2.191) port 80
* Server auth using Basic with user '***'
> POST /api/testAuth/node HTTP/1.1
> Authorization: Basic Ym1hYWRtaW46Ymlnd2hlZWxz
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: dev.bouldermountainbike.org
> Accept: */*
> Cookie: <cookie>
> Content-Type:application/json
> Content-Length: 156
> 
>       {          "type":"page",          "title":"Page submitted via Services",          "body":"Here is the body of an page submitted via Services."      }HTTP/1.1 200 OK
< Date: Thu, 28 Feb 2013 17:07:15 GMT
< Server: Apache/2.2.22 (Ubuntu)
< X-Powered-By: PHP/5.3.10-1ubuntu3.4
< Expires: Sun, 19 Nov 1978 05:00:00 GMT
< Last-Modified: Thu, 28 Feb 2013 17:07:15 GMT
< Cache-Control: store, no-cache, must-revalidate
< Cache-Control: post-check=0, pre-check=0
< Vary: Accept
< Content-Length: 80
< Content-Type: application/json
Connection #0 to host dev.bouldermountainbike.org left intact
* Closing connection #0
{"nid":"1504","uri":"http://dev.bouldermountainbike.org/api/testAuth/node/1504"}

Where have I gone wrong with the comment POST request?

Comments

boulderfuzz’s picture

Category: support » bug

After further testing, I believe there is a conflict with Comment Driven , which is running on my site.

I am able to post a valid comment if I disable Comment Driven (as above, I have used a fake username and password for the website):

curl -u username:password -H "Content-type: application/json" -b testCookies.txt http://dev.bouldermountainbike.org/api/testAuth/comment -d '{"nid":"175","comment":"comment_driven disabled, test comment"}'

{"cid":"3351","uri":"http://dev.bouldermountainbike.org/api/testAuth/comment/3351"}

With Comment Driven reenabled:

curl -u username:password -H "Content-type: application/json" -b testCookies.txt http://dev.bouldermountainbike.org/api/testAuth/comment -d '{"nid":"175","comment":"comment_driven now enabled"}'

["An illegal choice has been detected. Please contact the site administrator. Comment field is required (or a driven property change otherwise)."]

I just cross-posted to the Comment Driven issues queue: http://drupal.org/node/1938440

marcingy’s picture

Status: Active » Closed (won't fix)

This is an issue with comment driven as services simply 'fakes' doing a form submit. Update I have taken a quick look at the comment driven code to be honest it does many strange things the area of form altering, so I am not surprised that with the module in question enabled stuff does not work. Services does not support modules outside of core drupal so matter what happens in the other issue queue as far as services is concerned this issue being marked as won't fix is final.