MrMustafa
MrMustafa

Reputation: 305

Using jquery AJAX Post method in Google app script

I am using Google script for Google sheets and i want to run jQuery code in google script or use some method in google apps script to do like this:

var url = 'https://example.com/message?token=83763g87x';

var data = {
    money: '333', 
    body: 'Hello, Andrew!', // Message
};

// Send a request
$.ajax(url, {
    data : JSON.stringify(data),
    contentType : 'application/json',
    type : 'POST'
});

Upvotes: 0

Views: 1050

Answers (1)

Kevkeev13
Kevkeev13

Reputation: 389

There it is :

var url = 'https://example.com/message?token=83763g87x';

var data = {
    money: '333', 
    body: 'Hello, Andrew!', // Message
};

// Send a request
var options = {
  'method' : 'post',
  'contentType': 'application/json',
  // Convert the JavaScript object to a JSON string.
  'payload' : JSON.stringify(data)
};
UrlFetchApp.fetch(url, options);

Upvotes: 1

Related Questions