Skip to content

Instantly share code, notes, and snippets.

@nalgeon
Created February 21, 2017 14:47
Show Gist options
  • Save nalgeon/27a4ce85c6fc3f80f20c8d5b9084e627 to your computer and use it in GitHub Desktop.
Save nalgeon/27a4ce85c6fc3f80f20c8d5b9084e627 to your computer and use it in GitHub Desktop.
Пример работы с подсказками DaData на Google Apps Script
function getNameByINN(inn) {
var url = "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/party";
var query = '{"query": "' + inn + '"}'
var headers = {
"Authorization": "Token ВАШ_API_КЛЮЧ"
};
var fetchArgs = {
method: "POST",
contentType: "application/json",
payload: query,
headers: headers,
muteHttpExceptions: false
};
var response = JSON.parse(UrlFetchApp.fetch(url, fetchArgs));
var party = response.suggestions[0].data;
return {
success: 1,
name: party.name.short_with_opf,
type: party.type,
kpp: party.kpp
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment