This works just fine:
http://mysite.com/api/node?fields=nid,uid&parameters[uid]=1

But this ALWAYS return an empty set
http://mysite.com/api/comment?fields=nid,uid&parameters[uid]=1

This:

$query = services_resource_build_index_query('comments', 'c.timestamp DESC', $page, $fields, $parameters, 'c', 'cid', $page_title, 'comment');

Returns zero results, no matter the arguments. I tested it with var_dump.

The result is always:

<?xml version="1.0" encoding="utf-8"?>
<result/>

Am I doing something wrong, or there is a major bug in the module?
Thanks!

Comments

kylebrowning’s picture

Im not sure what mistakes you're making, does the user have permissions to access comments? Im getting results...

{14:00}~/Documents/Work/Drupal/drupal-6/sites/all/modules/services:6.x-3.x ✗ ➭ http GET http://d6.workhabit.com/api/comment Accept:application/json
HTTP/1.1 200 OK
Cache-Control: store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Content-Length: 526
Content-Type: application/json
Date: Tue, 09 Oct 2012 21:01:02 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Tue, 09 Oct 2012 21:01:02 GMT
Server: Apache
Set-Cookie: SESSe084ef31b5ec643674b50ea0cddce1a7=dec69caabeafc82982e3f8bc607c5a45; expires=Fri, 02-Nov-2012 00:34:22 GMT; path=/; domain=.d6.workhabit.com
Vary: Accept
X-Powered-By: PHP/5.2.17

[
    {
        "cid": "2", 
        "comment": "dfasdfasdf", 
        "format": "1", 
        "homepage": "", 
        "hostname": "127.0.0.1", 
        "mail": "", 
        "name": "admin", 
        "nid": "1", 
        "pid": "0", 
        "status": "0", 
        "subject": "asdfasdfasdf", 
        "thread": "02/", 
        "timestamp": "1349816362", 
        "uid": "1", 
        "uri": "http://d6.workhabit.com/api/comments/2"
    }, 
    {
        "cid": "1", 
        "comment": "asdfasdfasdf", 
        "format": "1", 
        "homepage": "", 
        "hostname": "127.0.0.1", 
        "mail": "", 
        "name": "admin", 
        "nid": "1", 
        "pid": "0", 
        "status": "0", 
        "subject": "fasdf", 
        "thread": "01/", 
        "timestamp": "1349816357", 
        "uid": "1", 
        "uri": "http://d6.workhabit.com/api/comments/1"
    }
]
kylebrowning’s picture

Status: Active » Closed (cannot reproduce)
tschellhorn’s picture

I came across this issue with using a regular user that did not have 'administer comments' access.

I think the problem comes up with how the code in the services/resources/comment_resource.inc file at line 210 to 212:

  if (!user_access('administer comments')) {
    $parameters['status'] = 1;
  }

When I looked up how the comments were listed, the "status" is opposite of a node status. For comments, "0" means "published" and "1" means unpublished.

To make it work for users that didn't have the 'administer comments' access, I changed it to the following:

  if (!user_access('administer comments')) {
    $parameters['status'] = COMMENT_PUBLISHED;
  }

I hope that helps track down the problem here.

I am using the services module version 6.x-3.3.

Trevor

tschellhorn’s picture

StatusFileSize
new608 bytes

Here is the patch for that to make it easier.

Trevor

Fidelix’s picture

Status: Closed (cannot reproduce) » Needs review
marcingy’s picture

Version: 6.x-3.1 » 7.x-3.x-dev
Priority: Major » Normal
Status: Needs review » Needs work

This needs to be fixed in 7.x first

jerenus’s picture

Mistake.

jerenus’s picture

Mistake.

jerenus’s picture

Mistake.

jerenus’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new1022 bytes

Patch for V6.

marcingy’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

Please do not change version this needs to be fixed in d7 first.

marcingy’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Reviewed & tested by the community

Ah ok my bad - rbtc it is then. Thank you :)

kylebrowning’s picture

Status: Reviewed & tested by the community » Needs review
kylebrowning’s picture

Status: Needs review » Reviewed & tested by the community
ygerasimov’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

jerenus’s picture

:)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

removing private info