Neil,
You can send json data directly to a databin. Here is an example:
In[1]:= bin = CreateDatabin[]
Out[1]= Databin["....."]
In[2]:= json =
ExportString[{"x" -> 11, "y" -> "foo", "z" -> True}, "JSON"]
Out[2]= "{
\"x\": 11,
\"y\": \"foo\",
\"z\": true
}"
In[3]:= URLFetch[
"https://datadrop.wolframcloud.com/api/v1.0/Add?Bin=" <> bin["UUID"],
"Body" -> json, "Headers" -> {"Content-Type" -> "application/json"},
"Method" -> "POST"]
Out[3]= "<|\"Message\" -> \"The data was successfully added.\", \"Bin\
\" -> \"DD56f1e2eac88-e905-4ee5-8b18-7c4bd6072f3c\", \"Data\" -> \
<|\"x\" -> 11, \"y\" -> \"foo\", \"z\" -> True|>, \"Timestamp\" -> \
{2015, 7, 27, 13, 34, 52.135154`8.46970563570117}, \"DataID\" -> \
\"data0bcbcb32-146b-44f5-bcc2-caf713ac9b7d\", \"Information\" -> \
{\"EntryCount\" -> 1, \"LatestTimestamp\" -> 3646992892, \"Size\" -> \
512}|>"
In[4]:= Values[bin]
A couple of things to keep in mind:
- Make sure the "Content-Type" header in your request is set to "application/json"
- Data Drop will use the first level of parameters in the json submission. It will not separate nested