0

I was wondering how to go about making a basic single dataset Plotly REST call using google apps scripts. Could someone please provide just a basic function that does this? It would greatly help me, and will try and help those in the future who help me. I think I'm getting hung up on adding the dataset. This what I have so far:

Let dataSet be a (nx2) array in the form [[date0, r0], [date1, r1], ..., [daten, rn]] s.t. date0 > daten and ri in the reals.

function plot(dataSet){

  var key = "XXXXXXXXXX";
  var url = "https://plot.ly/clientresp";
  var un = "un=XXXXXXX";
  var origin = "origin=plot";
  var platform = "platform=lisp";

  ...

  return plotlyUrlImage;

}

1 Answer 1

2

Use UrlFetchApp.fetch and specify it to be a post request.

function plot(dataSet){
  var key = "XXXXXXXXXX";
  var url = "https://plot.ly/clientresp";
  var un = "XXXXXX";
  var origin = "plot";
  var platform = "lisp";

  var payload = {
    "un": un,
    "key": key,
    "origin": origin,
    "platform": platform,
    "args": JSON.stringify(args),
    "kwargs": JSON.stringify(kwargs)
  };

  var options = {
    "method": "post",
    "payload": payload
  };

  var response = UrlFetchApp.fetch(url, options);
  var rs = JSON.parse(response.getContentText());

  return rs["url"];
}

Reference:

Sign up to request clarification or add additional context in comments.

1 Comment

Yes! Works like a charm! As soon as I get my rep up I'll vote up. Everyone please vote up for the above. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.