Created
February 21, 2017 14:47
-
-
Save nalgeon/27a4ce85c6fc3f80f20c8d5b9084e627 to your computer and use it in GitHub Desktop.
Пример работы с подсказками DaData на Google Apps Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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