0

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\"}\"}"}
3
  • 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. Commented May 13, 2014 at 14:08
  • sorry mate. yes, it's me again still on my adventures in parse land - have updated my question... see anything? Commented May 13, 2014 at 15:15
  • Have you tried to urlencoding only the jsonUser string instead of whole query? Commented May 13, 2014 at 15:46

1 Answer 1

1

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 + "}");
Sign up to request clarification or add additional context in comments.

1 Comment

you are awesome! - want a job?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.