En esta sección aprenderás cómo utilizar la API para obtener las comunas ingresadas en el sistema.
Para obtener las comunas ingresadas en el sistema utilizaremos el verbo http GET, los códigos de comunas son importantes al momento de crear contrapartes por ejemplo.
Formato de respuesta | JSON |
---|---|
¿Requiere autenticación? | SI |
¿Requiere token? | SI |
¿Requiere Partner key? | NO |
N/A
curl --location --request GET 'https://api.nubox.com/Nubox.API/factura/comunas' \ --header 'token: 8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2' \ --header 'Cookie: .Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da'
var settings = { "url": "https://api.nubox.com/Nubox.API/factura/comunas", "method": "GET", "timeout": 0, "headers": { "token": "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2", "Cookie": ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da" }, }; $.ajax(settings).done(function (response) { console.log(response); });
var myHeaders = new Headers(); myHeaders.append("token", "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2"); myHeaders.append("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://api.nubox.com/Nubox.API/factura/comunas", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { console.log(this.responseText); } }); xhr.open("GET", "https://api.nubox.com/Nubox.API/factura/comunas"); xhr.setRequestHeader("token", "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2"); xhr.setRequestHeader("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da"); xhr.send();
var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.nubox.com/Nubox.API/factura/comunas', 'headers': { 'token': '8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2', 'Cookie': '.Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da' } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
var client = new RestClient("https://api.nubox.com/Nubox.API/factura/comunas"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("token", "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2"); request.AddHeader("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nubox.com/Nubox.API/factura/comunas', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'token: 8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2', 'Cookie: .Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
require "uri" require "net/http" url = URI("https://api.nubox.com/Nubox.API/factura/comunas") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["token"] = "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2" request["Cookie"] = ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da" response = https.request(request) puts response.read_body
package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.nubox.com/Nubox.API/factura/comunas" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("token", "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2") req.Header.Add("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }
OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.nubox.com/Nubox.API/factura/comunas") .method("GET", null) .addHeader("token", "8b47950f-42cf-4ecd-9a9c-4bbcc86a86d2") .addHeader("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da") .build(); Response response = client.newCall(request).execute();
{ "698": "- SIN ESPECIFICAR -", "343": "ALGARROBO", "344": "ALHUE", "689": "ALTO BIO BIO", "345": "ALTO DEL CARMEN", "692": "ALTO HOSPICIO", "346": "ANCUD", "347": "ANDACOLLO", "348": "ANGOL", "696": "ANTARTICA", "350": "ANTOFAGASTA", "351": "ANTUCO", "352": "ARAUCO", "353": "ARICA", ... }
Nombre | Valor |
---|---|
cache-control | no-cache |
content-length | 0 |
content-type | application/json; charset=utf-8 |
date | Thu, 16 Apr 2020 22:53:54 GMT |