Pass a variable into payload data?

I am using Google Script to import data from GraphQL API into a sheet for dashboard purposes. I would like to automate the script every 24 hours to pull all data updated since the last batch.

Any time I try to pass a variable into my payload, it errors out. Can someone please give me a hand on appropriate syntax so that it is still a valid request?

var data ={"query": "query {\n 
orders( updated_from: \**"[[insert variable here]]"**){\n   
data {\n 
hasNextPage \n
 endCursor \n}  edges{\n   node{\n     order_number\n fulfillment_status\n rma_labels{\n status\n carrier\n tracking_number\n} shipments{\n      shipping_labels{\n order_number\n created_date\n  carrier\n tracking_number\n }\n }\n }\n }\n }\n}}"

    var payload = JSON.stringify(data);

    var headers = {
      "Accept": "application/xml",
      "Content-Type": "application/xml",
      "Authorization": "Bearer "+ token

    var options = {
      "method" : "post",
      "contentType": "application/json",
      muteHTTPExceptions : true,
      "headers" : headers,
      "payload" : payload

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

Hi @dlshaw!
Have you tried using variables? Ref.: ?
Please let us know if that doesn’t work.
Thanks in advance!

@dlshaw Good morning!

I’ve done this several times… let me know if you want to connect and I can walk you through it. :slight_smile: (