JSON Data is empty

When I check the pledges then I don’t get informations in data part.
You know this part: https://www.patreon.com/api/oauth2/api/campaigns/xxxxxx/pledges
I get respons only this:

"data": [],
"links": {
    "first": "https://www.patreon.com/api/oauth2/api/campaigns/xxxxxx/pledges?page%5Bcount%5D=10&sort=created"
"meta": {
    "count": 0

Why don’t I get in data part all informations? Or is it normal?
I use a chat bot and this is in C# programming language.

            using (var http = new HttpClient())
                                    http.DefaultRequestHeaders.Add("Authorization", "Bearer " + _creds.PatreonAccessToken);
                                    var data = new PatreonData()
                                        Links = new PatreonDataLinks()
                                            next = $"https://api.patreon.com/oauth2/api/campaigns/{_creds.PatreonCampaignId}/pledges"
                                        var res = await http.GetStringAsync(data.Links.next)
                                        data = JsonConvert.DeserializeObject<PatreonData>(res);
                                        var pledgers = data.Data.Where(x => x["type"].ToString() == "pledge");
                                        dynamic felhasznalok = JObject.Parse(res);
                                        rewards.AddRange(pledgers.Select(x => JsonConvert.DeserializeObject<PatreonPledge>(x.ToString()))
                                            .Where(x => x.attributes.declined_since == null));

                                        .Where(x => x["type"].ToString() == "user")
                                        .Select(x => JsonConvert.DeserializeObject<PatreonUser>(x.ToString())));
                                } while (!string.IsNullOrWhiteSpace(data.Links.next));

The problem is with this part:
.Where(x => x[“type”].ToString() == “user”)
.Select(x => JsonConvert.DeserializeObject(x.ToString())));

I get this error to above mentioned source part:
System.ArgumentNullException: Value cannot be null.
Parameter name: source

What is the problem? :slight_smile:

1 Like

The issue is with your api call, I think. Does the campaign you are querying the pledges for actually have pledges? And do you have permission to access that campaign’s pledges (it’s your campaign connected to the api client, or you have a multi creator campaign)?

The count field in meta seems to imply that your api call is returning 0 pledges.