Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Update metadata #22

Closed
timwis opened this issue Sep 27, 2016 · 3 comments
Closed

Update metadata #22

timwis opened this issue Sep 27, 2016 · 3 comments

Comments

@timwis
Copy link
Collaborator

timwis commented Sep 27, 2016

Just noticed there's a create method and a get_metadata method using the same endpoint, but no update method. Here's some relevant info from Socrata on the /api/views.json endpoint:

PUT to /api/views/unique_id.json with a subset of what you want to update. For instance, if you want to add tags to the previously created dataset (currently this is the only way to add tags), you can simply PUT to the endpoint with:

{
  "tags": ["these", "words", "are", "tags"]
}

You'll probably also want to make this dataset public and publish it, so you'll want to perform the two following operations as well:
PUT /views/unique_id?method=setPermission&value=public.read
POST /api/views/unique_id/publication.json

One important thing to note about updates is that if you want to update something within the "custom metadata", you will have to copy the entire metadata object since it does a replace.

Note that I've heard over the year(s) that the views endpoint is/will be deprecated, but until there's a clear alternative it probably makes sense to continue to use it.

Anyway, I may get a chance to work on this, but wanted to post the details here in case anyone else is interested.

@chrismetcalf
Copy link
Collaborator

chrismetcalf commented Sep 27, 2016

Be very careful with the /api/views/$id.json endpoint - there are things you can do by patching that payload that can damage your dataset or visualization configuration. In particular, updates to the metadata key need to be very carefully merged with the existing content in that part of the object, or you can overwrite dataset configuration that also resides there. Its best to make sure you're only PUTting the keys you want to actually update, and leave everything else out.

I've probably been one of those people over the years telling you about our plans to replace this API, as it is my top priority for replacement. However, until I can share more concrete plans with you, you're free to (carefully) use it. Please loop me in if you have any questions whatsoever, and I can make sure you're doing the right things.

With great power comes great responsibility. 😉

@xmunoz
Copy link
Owner

xmunoz commented Sep 28, 2016

Lolz you guys 😸

I should have time to implement something this weekend. Thanks for the heads up, and I'll let you know if I have any more questions. As always, pull requests are welcomed. If I get to it first though, I will likely ask both of you to review.

@timwis
Copy link
Collaborator Author

timwis commented Sep 29, 2016

That's awesome! Thanks :D

@xmunoz xmunoz closed this as completed in f084b33 Oct 4, 2016
xmunoz added a commit that referenced this issue Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants