# Getting 500 Internal Server Error from API

**URL:** <https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806>\
**Category:** Bugabee\
**Created:** [January 9, 2016, 4:43pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806 "2016-01-09T16:43:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenoubi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/kenoubi/32/842_2.png) [@kenoubi](https://forum.beeminder.com/u/kenoubi)\
**Post date:** [January 9, 2016, 4:43pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/1 "2016-01-09T16:43:53Z")

</div>

I’m playing with the API for the first time and I’m getting a 500 Internal Server Error when I PUT the following URL:

[https://www.beeminder.com/api/v1/users/kenoub/goals/marathon.json?username=kenoubi&roadall=[[1452963600%2C+null%2C+0.0]%2C+[1454259600%2C+null%2C+15.0]%2C+[1454864400%2C+null%2C+16.5]%2C+[1455469200%2C+null%2C+18.150000000000002]%2C+[1456074000%2C+null%2C+19.965000000000007]%2C+[1456678800%2C+null%2C+21.961500000000004]%2C+[1457283600%2C+null%2C+24.157650000000007]%2C+[1457888400%2C+null%2C+26.573415000000011]%2C+[1458493200%2C+null%2C+29.23075650000002]%2C+[1459098000%2C+null%2C+32.153832150000021]%2C+[1460390400%2C+null%2C+0.0]]&auth\_token=AUTH\_TOKEN](https://www.beeminder.com/api/v1/users/kenoub/goals/marathon.json?username=kenoubi&roadall=%5B%5B1452963600%2C+null%2C+0.0%5D%2C+%5B1454259600%2C+null%2C+15.0%5D%2C+%5B1454864400%2C+null%2C+16.5%5D%2C+%5B1455469200%2C+null%2C+18.150000000000002%5D%2C+%5B1456074000%2C+null%2C+19.965000000000007%5D%2C+%5B1456678800%2C+null%2C+21.961500000000004%5D%2C+%5B1457283600%2C+null%2C+24.157650000000007%5D%2C+%5B1457888400%2C+null%2C+26.573415000000011%5D%2C+%5B1458493200%2C+null%2C+29.23075650000002%5D%2C+%5B1459098000%2C+null%2C+32.153832150000021%5D%2C+%5B1460390400%2C+null%2C+0.0%5D%5D&auth_token=AUTH_TOKEN)

(I’m sending the actual auth token obviously, not literally AUTH\_TOKEN.) There are a number of aspects of what I’m doing that are weird, and there may be a good reason it should fail. But the 500 error isn’t helping me figure out what in particular is wrong.

---

<div class="post-metadata">

**Author:** ![kenoubi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/kenoubi/32/842_2.png) [@kenoubi](https://forum.beeminder.com/u/kenoubi)\
**Post date:** [January 9, 2016, 4:47pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/2 "2016-01-09T16:47:23Z")

</div>

Haha, and of course I had to post that before noticing the typo in my username in the URL 😄  
Still, 500 isn’t the right response to that, more of a 404 or 403.

---

<div class="post-metadata">

**Author:** ![kenoubi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/kenoubi/32/842_2.png) [@kenoubi](https://forum.beeminder.com/u/kenoubi)\
**Post date:** [January 9, 2016, 4:51pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/3 "2016-01-09T16:51:33Z")

</div>

Also, now that I did get it to run, I appear to have broken my goal (I have an error message instead of a graph). Which I don’t mind (I’m playing with fire, I expect to get burned), but it probably indicates some missing validation.

---

<div class="post-metadata">

**Author:** ![insti](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/insti/32/545_2.png) [@insti](https://forum.beeminder.com/u/insti)\
**Post date:** [January 9, 2016, 9:25pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/4 "2016-01-09T21:25:24Z")

</div>

The road editor API needs some work, particularly around providing helpful error messages.

Email support and they can fix your road, they’re usually helpful and encouraging towards feedback on what needs improving.

---

<div class="post-metadata">

**Author:** ![apb](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/apb/32/100_2.png) [@apb](https://forum.beeminder.com/u/apb)\
**Post date:** [January 9, 2016, 11:24pm UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/5 "2016-01-09T23:24:47Z")

</div>

How are you making the PUT request, with curl or with a library? Can you paste the response you’re getting?

I ask because I actually don’t see a 500 in the logs for this request. Thanks for the report!

Edit to be more specific: I see that we sent you back a 500, but Honeybadger didn’t send us a full stack trace so that we can see what actually happened.

Further edit: here’s the server log if anyone’s interested:

`Processing by Api::V1::GoalsController#update as JSON Parameters: {"username"=>"kenoubi", "roadall"=>"[[1452963600, null, 0.0], [1454259600, null, 15.0], [1454864400, null, 16.5], [1455469200, null, 18.150000000000002], [1456074000, null, 19.965000000000007], [1456678800, null, 21.961500000000004], [1457283600, null, 24.157650000000007], [1457888400, null, 26.573415000000011], [1458493200, null, 29.23075650000002], [1459098000, null, 32.153832150000021], [1460390400, null, 0.0]]", "auth_token"=>"[FILTERED]", "user_id"=>"kenoub", "id"=>"marathon"} Completed 500 Internal Server Error in 78ms (Views: 0.4ms)`

---

<div class="post-metadata">

**Author:** ![kenoubi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/kenoubi/32/842_2.png) [@kenoubi](https://forum.beeminder.com/u/kenoubi)\
**Post date:** [January 10, 2016, 1:37am UTC](https://forum.beeminder.com/t/getting-500-internal-server-error-from-api/1806/6 "2016-01-10T01:37:13Z")

</div>

I assume it’s the incorrect “user\_id” value that caused it? But I was using urllib2 from Python with a hack to send PUT requests as described at [http://stackoverflow.com/a/111988](http://stackoverflow.com/a/111988). It does work (well, I broke things in an unrelated way for unrelated reasons 🙂) when I use the correct user in the path.
