# HTTP 500 for create\_all.json

**URL:** <https://forum.beeminder.com/t/http-500-for-create-all-json/558>\
**Category:** Bugabee\
**Created:** [March 3, 2015, 3:39pm UTC](https://forum.beeminder.com/t/http-500-for-create-all-json/558 "2015-03-03T15:39:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppaulojr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/ppaulojr/32/129_2.png) [@ppaulojr](https://forum.beeminder.com/u/ppaulojr)\
**Post date:** [March 3, 2015, 3:39pm UTC](https://forum.beeminder.com/t/http-500-for-create-all-json/558/1 "2015-03-03T15:39:51Z")

</div>

I’m calling the API function POST `/users/u/goals/g/datapoints/create_all.json` and I’m getting a 500 Error

```
{ URL: https://www.beeminder.com/api/v1/users/me/goals/prayrosary/datapoints/create_all.json }, response: <NSHTTPURLResponse: 0x17e6afe0> { URL: https://www.beeminder.com/api/v1/users/me/goals/prayrosary/datapoints/create_all.json } { status code: 500, headers {
    "Cache-Control" = "no-cache";
    Connection = "keep-alive";
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Tue, 03 Mar 2015 15:35:25 GMT";
    Server = "nginx/1.4.7 + Phusion Passenger 4.0.41";
    "Set-Cookie" = "_beeminder_session=BAh7Bzoeb3JpZ2luYWxfb3JpZ2luYWxfcmVmZXJlckkiBi8GOgZFRkkiD3Nlc3Npb25faWQGOwZGIiVlNmMwZTBiMWI4NTU1ZDE1OWU1NDUzZTFhMjVkZTc4NQ%3D%3D--e32342f10f69f70212c74ccbe395e1353df14b9d; path=/; HttpOnly";
    Status = "500 Internal Server Error";
    "Transfer-Encoding" = Identity;
    "X-Powered-By" = "Phusion Passenger 4.0.41";
    "X-Runtime" = "0.396489";
    "X-UA-Compatible" = "IE=Edge,chrome=1";
} }> - Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 500" UserInfo=0x17deb220 {NSLocalizedRecoverySuggestion={"error":"Internal Server Error"},
```

---

<div class="post-metadata">

**Author:** ![bee](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/bee/32/41_2.png) [@bee](https://forum.beeminder.com/u/bee)\
**Post date:** [March 4, 2015, 5:18am UTC](https://forum.beeminder.com/t/http-500-for-create-all-json/558/2 "2015-03-04T05:18:04Z")

</div>

The problem here is that you were passing in a proper form/urlencoded array of datapoints, while we were expecting a json-encoded string representation of the same. Which is kind of weird, and poorly documented [1], so shame on us!

The trouble here is deep… we return json data through the api, but we don’t really _accept_ json data posted to the api – it’s all x-www-form-urlencoded data.

If you want to pass in a thing like an array of arrays (`roadall`), or an array of datapoint parameters (`create_all`), we were asking you to construct your array, then turn it into a json-parsable string, pass us that, then we parse the string as json on our end.

This is admittedly surprising / confusing (perhaps we should make it [an _actual_ json api for v2](http://forum.beeminder.com/t/api-version-2-planning-and-wishlist/509/4)). You _can_ send nested lists and things with x-www-form-urlencoded data as well, but it’s kinda ugly [2] if you’re trying to curl things, for example. Of course if you have a nice civilized library doing the dirty work on your http calls it’s beneath you to worry about such things anyway. So what I just did makes it so you can submit form-data-url-encoded arrays, or you can submit the json-encoded string version.

This should work for both `roadall` and `datapoints#create_all` in the api now.

[1] I think this used to be better documented and we may have murked it up in the past several months. I believe this because I know that people have successfully used the `datapoints#create_all` endpoint in the past. Sorry!

[2] this example is borrowed from [HTTParty](https://github.com/jnunemaker/httparty "My favorite kind of party")

```ruby
@example
  # { name: "Bob",
  # address: {
  # street: '111 Ruby Ave.',
  # city: 'Ruby Central',
  # phones: ['111-111-1111', '222-222-2222']
  # }
  # }.to_params
  # => "name=Bob&address[city]=Ruby Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111 Ruby Ave."

```

---

<div class="post-metadata">

**Author:** ![bee](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/bee/32/41_2.png) [@bee](https://forum.beeminder.com/u/bee)\
**Post date:** [March 4, 2015, 6:17am UTC](https://forum.beeminder.com/t/http-500-for-create-all-json/558/4 "2015-03-04T06:17:58Z")

</div>

Whoops, edited my original answer because I was wrong. If you get these by email you might want to check out the updated answer in-forum.

Cheers!  
B

---

<div class="post-metadata">

**Author:** ![ppaulojr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/ppaulojr/32/129_2.png) [@ppaulojr](https://forum.beeminder.com/u/ppaulojr)\
**Post date:** [March 4, 2015, 3:46pm UTC](https://forum.beeminder.com/t/http-500-for-create-all-json/558/5 "2015-03-04T15:46:51Z")

</div>

It seems to be working now.
