Heads Up! The ability to modify a dataset requires special permissions.
The Socrata Publisher
replace API allows you replace your dataset entirely using a single HTTP
PUT request. This is an excellent way to load your Socrata dataset the first time, or get it back in sync when things have gone wrong.
Please note that all operations that modify datasets must be authenticated as a user who has access to modify that dataset, and must be accompanied by an application token.
The dataset for this example is the USGS Earthquakes Sample Dataset, which has its publisher-specified row identifier set to
We’ll format our payload as a JSON array of objects, just like you did for upsert. This example contains only a few records, but replacement operations can easily contain thousands of records at a time.
Once you’ve constructed your payload, upserting it is as simple as using an HTTP
PUT request on your dataset’s endpoint, along with the appropriate authentication and application token information:
You’ll get back a response detailing what went right or wrong:
That means we replaced the content of the dataset with two records.
You can use properly-formatted “Comma Separated Value” (CSV) data to do updates, just like you can do with JSON. Just make sure you follow a few rules:
Marc "Dr. Complainingstone" Millstonewould become
"Marc ""Dr. Complainingstone"" Millstone")
Here’s an example:
Source,Earthquake ID,Version,Datetime,Magnitude,Depth,Number of Stations,Region,Location demo,demo1234,1,03/26/2014 10:38:01 PM,1.2,7.9,1,Washington,"(47.59815, -122.334540)" nc,71842370,2,09/14/2012 10:14:21 PM,1.4,0,21,Northern California,"(38.8023, -122.7685)"
Just like before, upserting it is as simple as
POSTing it to your dataset’s endpoint, along with the appropriate authentication and application token information. Make sure you use a content type of
You’ll get back a response like you did in the previous example, detailing what went right and wrong: