M.O.A. - Declaración


Solicitud
import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
    "encoding/json"
)

// Deben cambiar los datos de "params" por los que correspondan. 
// Esta request de ejemplo incluye todos posibles valores para 
// llamar al metodo BloqueosLista, puede que algun valor sea opcional.
requestData, _ := json.Marshal(map[string]any {
    "environment" : "prod",
    "method" : "BloqueosLista",
    "wsid" : "wconsdeclaracion",
    "params" : map[string]any {
        "argWSAutenticacionEmpresa" : map[string]any {
            "Token" : "string",
            "Sign" : "string",
            "CuitEmpresaConectada" : 1,
            "TipoAgente" : "string",
            "Rol" : "string",
        },
        "argBloqueosListaParam" : map[string]any {
            "CuitImportadorExportador" : "string",
            "CuitDespachante" : "string",
            "IdentificadorDeclaracion" : "string",
            "FechaOficializacionDesde" : "YYYY-MM-DDThh:mm:ss",
            "FechaOficializacionHasta" : "YYYY-MM-DDThh:mm:ss",
            "CodigoAduanaRegistro" : "string",
            "CodigoTipoOperacion" : "string",
            "CodigoSubregimen" : "string",
            "CodigoTipoBloqueo" : "string",
            "IndicadorBloqueoAutorizado" : "string",
        },
    },
})

// Creamos un cliente HTTP para llamar a la API
clientRequest := &http.Client {}
urlRequest := "https://app.afipsdk.com/api/v1/afip/requests"
methodRequest := "POST"
reqRequest, _ := http.NewRequest(methodRequest, urlRequest, strings.NewReader(string(requestData)))

// Reemplazar con tu access_token obtenido de https://app.afipsdk.com
accessToken := "TU_TOKEN_AQUI"
reqRequest.Header.Add("Authorization", "Bearer " + accessToken)

// Realizamos la llamada a la API
reqRequest.Header.Add("Content-Type", "application/json")
resRequest, _ := clientRequest.Do(reqRequest)
defer resRequest.Body.Close()
bodyRequest, _ := ioutil.ReadAll(resRequest.Body)

// En caso de error lo mostramos por consola
if resRequest.StatusCode >= 400 {
    var responseError map[string]any
    json.Unmarshal([]byte(string(bodyRequest)), &responseError)
    responseErrorString, _ := json.MarshalIndent(responseError, "", "    ")
    fmt.Println(string(responseErrorString))
    return
}

// Convertimos la respuesta en un objeto
var response map[string]any
json.Unmarshal([]byte(string(bodyRequest)), &response)

// Mostramos la respuesta por consola
responseString, _ := json.MarshalIndent(response, "", "    ")
fmt.Println(string(responseString))
Respuesta
{
    "BloqueosListaResult": {
        "ListaErrores": {
            "DetalleError": [
                {
                    "Codigo": "integer",
                    "Descripcion": "string",
                    "DescripcionDetallada": "string",
                    "TextoAclaratorio": "string",
                    "DescripcionAdicional": "string",
                    "Parametros": {
                        "string": [
                            "string"
                        ]
                    }
                }
            ]
        },
        "Server": "string",
        "TimeStamp": "datetime",
        "Destinaciones": {
            "Destinacion": [
                {
                    "IdentificadorDeclaracion": "string",
                    "CuitImportadorExportador": "string",
                    "CuitDespachante": "string",
                    "FechaOficializacionDeclaracion": "datetime",
                    "CodigoEstadoDeclaracion": "string",
                    "FechaEstadoDeclaracion": "datetime"
                }
            ]
        }
    }
}