# Rewards data not included in API response

**URL:** <https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158>\
**Category:** Friendly Help\
**Created:** [December 12, 2017, 11:25am UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158 "2017-12-12T11:25:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinkas](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/vinkas/32/72_2.png) [@vinkas](https://www.patreondevelopers.com/u/vinkas)\
**Post date:** [December 12, 2017, 11:25am UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/1 "2017-12-12T11:25:18Z")

</div>

Hi there,

```css
/oauth2/api/campaigns/ID/pledges?include=rewards,creator,goals,pledges

```

In above API endpoint previously we received the rewards for the appropriate pledges. Recently the responses are not including the rewards data. Is there anything changed recently?

---

<div class="post-metadata">

**Author:** ![LordHarvie](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@LordHarvie](https://www.patreondevelopers.com/u/LordHarvie)\
**Post date:** [December 12, 2017, 6:03pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/2 "2017-12-12T18:03:52Z")

</div>

Seems to work fine for me. Any chance of a typo in the actual request?

---

<div class="post-metadata">

**Author:** ![vinkas](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/vinkas/32/72_2.png) [@vinkas](https://www.patreondevelopers.com/u/vinkas)\
**Post date:** [December 12, 2017, 6:27pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/3 "2017-12-12T18:27:48Z")

</div>

It can’t be a typo for two reasons.

1. We are getting the URL from campaigns API response value at `data >> relationships >> pledges >> links >> first`. And not using the raw URL directly in the code.

2. It is untouched working code for more than 2 weeks. But the problem is raising now only.

Below is the URL we receiving from campaigns API endpoint `/oauth2/api/current_user/campaigns?include=rewards,creator,goals,pledges`.

```auto
https://www.patreon.com/api/oauth2/api/campaigns/[ID]/pledges?include=rewards%2Ccreator%2Cgoals%2Cpledges&page%5Bcount%5D=100

```

Edit: Again I rechecked it. Sure I am not receiving the values at `data >> type: pledge >> relationships >> reward`.

---

<div class="post-metadata">

**Author:** ![LordHarvie](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@LordHarvie](https://www.patreondevelopers.com/u/LordHarvie)\
**Post date:** [December 13, 2017, 3:20pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/4 "2017-12-13T15:20:29Z")

</div>

This happened a few days ago:

> **[Minor fixes to pledges endpoint](http://www.patreondevelopers.com/t/minor-fixes-to-pledges-endpoint/155)**
>
> Hey all, I’m one of the engineers on the Platform team. Just wanted to put in a quick plug for some fixes that we’ve implemented on the pledges endpoint. In addition to sorting on (-)created, you can sort on (-)updated: This used to cause a 500...

If you were using the Links provided and adding on your own include and field query parameters, this might be screwing things up if those parameters are now already in the link. Seems to coincide when things started going wrong for you?

---

<div class="post-metadata">

**Author:** ![vinkas](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/vinkas/32/72_2.png) [@vinkas](https://www.patreondevelopers.com/u/vinkas)\
**Post date:** [December 13, 2017, 3:32pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/5 "2017-12-13T15:32:36Z")

</div>

Great catch! Things went wrong exactly after the time of that post.

> [@LordHarvie](#):
>
> If you were using the Links provided and adding on your own include and field query parameters

I am not adding anything extra. I just using the link what they provided.

---

<div class="post-metadata">

**Author:** ![LordHarvie](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@LordHarvie](https://www.patreondevelopers.com/u/LordHarvie)\
**Post date:** [December 13, 2017, 5:16pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/6 "2017-12-13T17:16:23Z")

</div>

If you were not adding anything extra, then how were you getting the includes? Previously, the links that they provided did not have any of the include or field query parameter.

Perhaps with these changes, rewards aren’t added in by default anymore. Either way, you probably want to verify and modify the link that they are giving you.

---

<div class="post-metadata">

**Author:** ![vinkas](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/vinkas/32/72_2.png) [@vinkas](https://www.patreondevelopers.com/u/vinkas)\
**Post date:** [December 13, 2017, 6:02pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/7 "2017-12-13T18:02:53Z")

</div>

At last I found the problem.

I am adding `include` param in the API call of campaigns endpoint like `'/api/current_user/campaigns?include=rewards,creator,goals,pledges&page[count]=100'`.

In the response the same `include` param automatically added into the values at `data >> relationships >> pledges >> first & next`.

Like `/api/campaigns/[ID]/pledges?include=rewards,creator,goals,pledges&page%5Bcount%5D=20&sort=created`.

Both are different API endpoints. First one’s `include` param shouldn’t added to the second. Is it a bug 🐛? yes

Now I have to do like below

```ruby
uri.sub("include=rewards%2Ccreator%2Cgoals%2Cpledges&", "");

```

---

<div class="post-metadata">

**Author:** ![jeffrey](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/jeffrey/32/8_2.png) [@jeffrey](https://www.patreondevelopers.com/u/jeffrey)\
**Post date:** [December 13, 2017, 7:27pm UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/8 "2017-12-13T19:27:38Z")

</div>

Great catch, @vinkas. This is definitely a bug. I’ll merge a fix ASAP.

---

<div class="post-metadata">

**Author:** ![jeffrey](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/jeffrey/32/8_2.png) [@jeffrey](https://www.patreondevelopers.com/u/jeffrey)\
**Post date:** [December 14, 2017, 12:33am UTC](https://www.patreondevelopers.com/t/rewards-data-not-included-in-api-response/158/9 "2017-12-14T00:33:20Z")

</div>

After further investigation, it’s become clear that this is a larger issue which requires a more holistic approach to fix. I don’t feel comfortable leaving it in this buggy state, so I’m going to revert the “remember query params in includes” feature. We’ll be addressing this issue in the following weeks. You can expect a revert in the next hour. Sorry about this ☹
