Error in using Google Sheets API to add value in Google Sheets

Error in using Google Sheets API to add value in Google Sheets

Hi,

I am using the following code to add values in google sheets through custom functions. I am not able to figure out correct way of adding values in the invoke uRL. Can anyone help me out.

I am attaching the code and the error message which we are getting.

info rowNum;
range = "D" + rowNum;
value = [["a","B"]];
gSheetWriteParam = Map();
gSheetWriteParam.put("valueInputOption","RAW");
gSheetWriteParam.put("data", {"values":value});
response = invokeurl
[
url :"https://sheets.googleapis.com/v4/spreadsheets/" + spreadsheetId + "/values/Data!" + range
type :PUT
parameters:gSheetWriteParam
connection:"gsheet"
];
info response;



Error Message:

{"error":{"code":400,"message":"Invalid JSON payload received. Unknown name \"data\": Cannot bind query parameter. 'data' is a message type. Parameters can only be bound to primitive types.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"description":"Invalid JSON payload received. Unknown name \"data\": Cannot bind query parameter. 'data' is a message type. Parameters can only be bound to primitive types."}]}]}}