codeforamerica / city_developer_resources

API and Open Source project documentation site for cities that (hopefully) doesn't suck.
2 stars 5 forks source link

Docs poorly describes how to format attributes when POSTing to requests.:format #5

Open stevevance opened 11 years ago

stevevance commented 11 years ago

Docs in question: http://dev.cityofchicago.org/docs/api/post_service_request

The docs say to format the attribute parameter like attribute[code1][]=value1&attribute[code1][]=value2&attribute[code1][]=value3.

In JavaScript, I wrote var attributeStr = "attribute[WOULDYO2]=YES&attribute[DOESTHE1]=YES&attribute[WHEREIST]=ALLEY"; and created an options object: var options = {api_key: apiKey, service_code: "4fd3b656e750846c53000004", attribute : attributeStr, lat: lat, long: lng, address_string: addressStr };

This returns with [{"code":400,"description":"Failed to submit request: Validation failed - Details is invalid, Activities is invalid."}] I have no idea what that means. What are the details and activities that could be invalid? I see this nowhere in the docs.

This is incorrect. The correct way is to make each attribute an individual parameter: var options = { api_key: apiKey, service_code: "4fd3b656e750846c53000004", "attribute[WOULDYO2]": "YES", "attribute[DOESTHE1]": "YES", "attribute[WHEREIST]": "ALLEY", lat: lat, long: lng, address_string: addressStr };

This returns with [{"token":"50d15dc5016326d1efd8e935"}]

Mr0grog commented 11 years ago

Ah, I guess it is a bit unclear that the descriptive text is describing the querystring you should wind up with in the end and not the value you should be sending for the argument named "attribute" (which doesn't really quite exist).

Would this be better?

Rather than sending an argument named "attribute" you should specify several arguments named like attribute[CODE] where CODE is the attribute code from calling services/:service_code.:format. If the attribute's datatype is multivaluelist, you can specify several arguments, all named like attribute[CODE][].

Feel free to take a stab at something else if that's not clear. You can file a pull request for it, too ;)

stevevance commented 11 years ago

I don't know if that's any clearer. I like to see examples, like the two I provided. I don't know where the code is and I don't know how to make a pull request.

Mr0grog commented 11 years ago

Ok. I agree examples would be great, but my understanding of how this app is put together is that that is probably kind of complicated (whereas changing the wording of the description is quite simple).

Not sure where the best place to start on that is, though hopefully @boundsj (the primary author of this project) might have some good pointers. We'll see if he chimes in.

boundsj commented 11 years ago

The City of Chicago is hosting and supporting this app in Chicago now. Change requests should be sent directly to them.

The CfA repo will eventually be de-chicagoized so it can be more easily used in other places and on other types of APIs. So, all Open311 / Chicago specific content will be removed from the repo.

If you are unable to get a response from the Chicago dev team, feel free to contact me directly and I can try to help with the communications.

Thanks

On Wednesday, December 19, 2012, Rob Brackett wrote:

Ok. I agree examples would be great, but my understanding of how this app is put together is that that is probably kind of complicated (whereas changing the wording of the description is quite simple).

Not sure where the best place to start on that is, though hopefully @boundsj https://github.com/boundsj (the primary author of this project) might have some good pointers. We'll see if he chimes in.

— Reply to this email directly or view it on GitHubhttps://github.com/codeforamerica/city_developer_resources/issues/5#issuecomment-11521186.

Jesse Bounds 2012 Fellow @ Code for America http://codeforamerica.org/ 626 600 1976 @boundsj https://twitter.com/boundsj/ three sentences http://three.sentenc.es/

stevevance commented 11 years ago

I haven't yet submitted this to the Chicago dev team. I will just forward them this page.