Answer the question
In order to leave comments, you need to log in
Google sheets JSON.parse by API. How?
Help understand. I've been fighting for 4 days now and I don't understand.
I have a task. Insert the rest of the goods into the Google spreadsheet by api ozon.
The code
function getBaseUsers() {
var options = {
method: "POST",
"contentType" : "application/json",
"headers" : {
"Client-Id": "XXX",
"Api-Key": "XXX-XXX-XXX",
//"Content-Type": "application/json"
},
"payload": {
"page": 0, // Номер страницы, возвращаемой в запросе.
"page_size": 0 // Количество элементов на странице.
}
}
var response = UrlFetchApp.fetch("https://api-seller.ozon.ru/v2/product/info/stocks", options);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getSheetByName("Лист1");
var dataSet = dataAll.items;
var rows = [],
data;
for (i = 0; i < dataSet.length; i++) {
data = dataSet[i];
rows.push([data.data.offer_id, data.data.type, data.data.present]);
}
dataRange = sheet.getRange(2, 1, rows.length, 3);
dataRange.setValues(rows);
}
{
"page": 0,
"page_size": 0
}
Ошибка
Exception: Request failed for https://api-seller.ozon.ru returned code 400. Truncated server response: {"code":3, "message":"invalid character 'p' looking for beginning of value", "details":[]} (use muteHttpExceptions option to examine full response)
Answer the question
In order to leave comments, you need to log in
As written in the documentation
// Make a POST request with a JSON payload.
var data = {
'name': 'Bob Smith',
'age': 35,
'pets': ['fido', 'fluffy']
};
var options = {
'method' : 'post',
'contentType': 'application/json',
// Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data)
};
UrlFetchApp.fetch('https://httpbin.org/post', options);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question