Answer the question
In order to leave comments, you need to log in
Google Sheets and the OZON API. How to unload leftovers?
I'm trying to connect to the OZON API in order to automatically display the balances in a Google spreadsheet.
I try like this:
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Лист1");
var row = sheet.getRange(2,2);
var options = {
method: "POST",
headers: {
'Client-Id': 'XXX',
'Api-Key': 'XXX',
'accept': 'application/json'
}
}
var response = UrlFetchApp.fetch("https://api-seller.ozon.ru/v1/product/list", options);
var data = JSON.parse(response);
Logger.log(data)
}
Exception: Request failed for https://api-seller.ozon.ru returned code 400. Truncated server response: {"error":{"code":"BAD_REQUEST","message":"Invalid JSON payload","data":[{"name":"cause","code":"","value":"invalid character 'A' looking for beginn... (use muteHttpExceptions option to examine full response)
Answer the question
In order to leave comments, you need to log in
You don't have a request yourself. Here are examples - OZON Seller API: Get product description
const API_URL = "https://api-seller.ozon.ru";
const endpoint = "/v1/product/list";
let options = {
method: "POST",
headers: {
'Client-Id': 'XXX',
'Api-Key': 'XXX',
'accept': 'application/json'
},
payload:{
"filter": {
"offer_id": [
"string" // задайте значение или список
],
"product_id": [
0 // задайте значение или список
],
"visibility": "ALL" /* "ALL" "VISIBLE" "INVISIBLE" "EMPTY_STOCK" "NOT_MODERATED" "MODERATED" "DISABLED" "STATE_FAILED" "READY_TO_SUPPLY" "EMPTY_NAVIGATION_CATEGORY" "VALIDATION_STATE_PENDING" "VALIDATION_STATE_FAIL" "VALIDATION_STATE_SUCCESS" "TO_SUPPLY" "IN_SALE" "REMOVED_FROM_SALE" "ARCHIVED" */
},
"page": 0, // Номер страницы, возвращаемой в запросе.
"page_size": 0 // Количество элементов на странице.
}
};
let response = UrlFetchApp.fetch(API_URL + endpoint, options);
let data = JSON.parse(response);
Logger.log(data);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question