Writing data with a PUT request:
curl -X PUT -d '{ "first": "Jack", "last": "Sparrow" }' \ https://SampleChat.firebaseIO-demo.com/users/jack/name.json
I can issue a PUT request with Google Apps Script:UrlFetchApp.fetch("http://example.com/file.ext",
"method" : "put",
"payload
" : {"Payload String"});
But the curl command has -X and -d
-d, --data <data>
So I guess -d indicates that the data follows.
With Google Apps ScriptUrlFetchApp.fetch, there is a "payload" parameter. There example shows:
var payload =
-X, --request <command>
{
"fieldOne" : "value for field one",
"fieldTwo" : "value for field two",
"fileAttachment": fileBlob
};
Maybe the "Payload" converts to the -d cURL parameter? I don't know?
http://curl.haxx.se/docs/manpage.html
So, -X is the type of request? I'm looking at some cURL documentation, and I guess that's what the -X is for,
the PUT, PUSH, GET, DELETE type of request.
So maybe I can use this. It would probably be something like:UrlFetchApp.fetch("
https://SampleChat.firebaseIO-demo.com/users/jack/name.json
",
"method" : "put",
"payload
" :
'{ "first": "Jack", "last": "Sparrow" }'
);
Okay, I just opened up the firebase SampleChat database. Maybe I'll try to test write the previous line of code and see what happens.