Google apps script Urlfetchapp.fetch中的参数无效

Google apps script Urlfetchapp.fetch中的参数无效,google-apps-script,google-sheets,Google Apps Script,Google Sheets,当我请求帖子时,我的脚本有问题,它总是返回无效参数。我不知道我的json参数是否导致了这个问题。请帮帮我 function getWallet() { var header = { "contentType": "application/json", "headers": { "Authorization": "xxxxxxxxx",

当我请求帖子时,我的脚本有问题,它总是返回
无效参数
。我不知道我的json参数是否导致了这个问题。请帮帮我

function getWallet() {
    var header = {
        "contentType": "application/json",
        "headers": {
            "Authorization": "xxxxxxxxx",
        }
    };

    var dataRequestPost = {
        "amount": 5.95,
        "email": {
            "recipient_email": "customer@acme.com",
            "subject": "Rebate has arrived",
            "message": "Thank you for using our service."
        },
        "ref": {
            "order_id": "string",
            "email": "string",
            "id1": "string",
            "id2": "string",
            "phone_number": "string"
        },
        "add_to_blacklist": false
    };
  
    var rUrl = encodeURI('https://data.seller.tools/api/v1/wallet/paypal/USD');
  
    var executeRequest = {
        'url': rUrl,
        'method': 'post',
        'payload': dataRequestPost
    };
  
    var response = UrlFetchApp.fetch(executeRequest, header);
    var object = JSON.parse(response.getContentText());
  
    Logger.log(object);
}

您包含了所有正确的数据,只是没有按照预期的方式。它应该是
UrlFetchApp.fetch(url,params)
,其中
params
包括所有其他数据,如方法、头和负载

function getWallet() {
  var dataRequestPost = {
    "amount": 5.95,
    "email": {
      "recipient_email": "customer@acme.com",
      "subject": "Rebate has arrived",
      "message": "Thank you for using our service."
    },
    "ref": {
      "order_id": "string",
      "email": "string",
      "id1": "string",
      "id2": "string",
      "phone_number": "string"
    },
    "add_to_blacklist": false
  };
  var rUrl = encodeURI('https://data.seller.tools/api/v1/wallet/paypal/USD');
  var response = UrlFetchApp.fetch(rUrl, {
    "method": "post",
    "contentType": "application/json",
    "headers": {
      "Authorization": "xxxxxxxxx",
    },
    "payload": JSON.stringify(dataRequestPost)
  });
  var object = JSON.parse(response.getContentText());
  Logger.log(object);
}