Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a class called AccountData and I would like to return all rows that relate to a particular user. In the class I have a Pointer to the User table which contains their "ObjectId"

I have tried with the following call to the API:

string url = "https://api.parse.com/1/classes/AccountData?" + WebUtility.UrlEncode("where={\"user\":\"fvJ8jPjyjx\"}");

where the fvJ8jPjyjx is the ObjectId of the user I want rows relating to...

The api doesn't throw any errors just returns:

{"results":[]}

I have also tried it using a "User Object" as follows:

public class AccountDataUser
{
    public string __type { get; set; }
    public string className { get; set; }
    public string objectId { get; set; }
}

building the object as follows:

AccountDataUser user = new AccountDataUser();
user.__type = "Pointer";
user.className = "_User";
user.objectId = objectId;
string jsonUser = JsonConvert.SerializeObject(user);

but this throws an api error.

Can anyone help me return the rows relating to a "user" please?

Thanks

UPDATE

Based on Ryans feedback I have reverted to trying to send an object...

This is what is being sent:

GET https://api.parse.com/1/classes/AccountData?where%3D%7B%22user%22%3A%22%7B%22__type%22%3A%22Pointer%22%2C%22className%22%3A%22_User%22%2C%22objectId%22%3A%22fvJ8jPjyjx%22%7D%22%7D HTTP/1.1
Content-Type: application/json
X-Parse-Application-Id: xxxxx
X-Parse-REST-API-Key: xxxxxx
Host: api.parse.com
Connection: Keep-Alive

The url is built with this line of code:

ParseModel.AccountDataUser user = new ParseModel.AccountDataUser();
user.__type = "Pointer";
user.className = "_User";
user.objectId = objectId;

string jsonUser = JsonConvert.SerializeObject(user);

string url = "https://api.parse.com/1/classes/AccountData?" + WebUtility.UrlEncode("where={\"user\":\"" + jsonUser + "\"}"); // this doesn't work

And the error I receive from the API is:

{"code":107,"error":"invalid json: {\"user\":\"{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"fvJ8jPjyjx\"}\"}"}
share|improve this question
1  
You need to pass a pointer object so your second attempt seems close. What does the resulting URL look like? I'm guessing a malformed URL is the issue. –  Ryan Duffy May 13 at 14:08
    
sorry mate. yes, it's me again still on my adventures in parse land - have updated my question... see anything? –  Trevor Daniel May 13 at 15:15
    
Have you tried to urlencoding only the jsonUser string instead of whole query? –  Luca Iaco May 13 at 15:46

1 Answer 1

up vote 1 down vote accepted

I believe the issue is in building the URL. You're wrapping the JSON in a string and Parse is expecting an object. If you strip the double quote around jsonUser, I bet that'll work.

string url = "https://api.parse.com/1/classes/AccountData?" + WebUtility.UrlEncode("where={\"user\":" + jsonUser + "}");
share|improve this answer
    
you are awesome! - want a job? –  Trevor Daniel May 13 at 16:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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