Answer the question
In order to leave comments, you need to log in
How to create a request for Nova Poshta from google script?
Hello.
I'm trying to get a list of cities in Nova Poshta from a google script.
async function novaPoshta () {
var headers = {
'Content-Type': 'application/json',
'apiKey': '***************'
};
var options = {
'method' : 'POST',
'headers': headers,
'modelName': 'Address',
'calledMethod': 'getCities',
}
var result = await UrlFetchApp.fetch('https://api.novaposhta.ua/v2.0/json/getCities', options);
let orderList = JSON.parse(result.getContentText());
Logger.log(orderList);
};
{data=[], info=[], errorCodes=[], warningCodes=[], warnings=[], messageCodes=[], success=false, infoCodes=[], errors=[Data is invalid]}
Answer the question
In order to leave comments, you need to log in
Do this:
function getCities () {
const formData = {
// Ваш ключ API 2.0
"apiKey": apiKey,
"modelName": "Address",
"calledMethod": "getCities"
};
const options = {
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"payload": JSON.stringify(formData)
};
const url = "https://api.novaposhta.ua/v2.0/json/getCities";
const response = UrlFetchApp.fetch(url, options);
Logger.log( response.getContentText() );
return response.getContentText();
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question