### C# Web Service Interaction Source: https://docs.afipsdk.com/siguientes-pasos/web-services/otro-web-service.md This C# example demonstrates how to use the AFIP library to interact with web services. It shows how to get an authorization token and execute a request for the 'wsct' service, similar to the Python example. ```csharp // Nombre del web service. // // El nombre por el cual se llama al web service en AFIP. // Esto lo podes encontrar en el manual correspondiente. // Por ej. el de factura electronica se llama "wsfe", el de // comprobantes T se llama "wsct" string servicio = "wsct"; // Creamos el web service AfipWebService genericWebService = afip.WebService(servicio); // Obtenemos el Token Authorization var ta = await genericWebService.GetTokenAuthorizationAsync(); // Preparamos los datos que nos pide el web service // // Este ejemplo es especifico para el wsct. En el manual // del web service que quieras utilizar encontraras que // datos requiere cada metodo var data = new Dictionary { ["authRequest"] = new Dictionary { ["token"] = ta["token"], ["sign"] = ta["sign"], ["cuitRepresentada"] = afip.CUIT }, ["codigoTipoComprobante"] = 195, ["numeroPuntoVenta"] = 1 }; try { // Ejecutamos la request al web service // // consultarUltimoComprobanteAutorizado es un metodo // de wsct, esto debes cambiarlo por el metodo que // quieras utilizar var result = await genericWebService.ExecuteRequestAsync>("consultarUltimoComprobanteAutorizado", data); // Mostramos el resultado Console.WriteLine(JsonSerializer.Serialize(result)); } catch (Exception ex) { // Si hubo un error lo logeamos Console.Error.WriteLine(ex.Message); } ``` -------------------------------- ### Initialize WSCT Web Service Instance Source: https://docs.afipsdk.com/siguientes-pasos/web-services/comprobantes-de-turismo.md Instantiate the 'wsct' web service. This is the first step before making any requests. ```js const ws = afip.WebService('wsct'); ``` ```php $ws = $afip->WebService('wsct'); ``` ```ruby ws = afip.webService("wsct") ``` ```python ws = afip.webService("wsct") ``` ```csharp AfipWebService ws = afip.WebService("wsct"); ``` ```java AfipWebService ws = afip.webService("wsct"); ``` -------------------------------- ### API Request for Get Taxpayer Details Source: https://docs.afipsdk.com/siguientes-pasos/web-services/padron-alcance-10.md Example JSON payload for calling the API to get taxpayer details. Requires environment, method, wsid, and parameters including token, sign, cuitRepresentada, and idPersona. ```json { "environment": "dev", "method": "getPersona", "wsid": "ws_sr_padron_a10", "params": { "token": "{{token}}", "sign": "{{sign}}", "cuitRepresentada": "20409378472", "idPersona" : 20111111111 } } ``` -------------------------------- ### Instantiate Web Service (.NET) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Create an instance of the 'wscpe' web service for .NET. ```csharp AfipWebService ws = afip.WebService("wscpe"); ``` -------------------------------- ### API Request for Currency Types Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica.md This is an example of an API request to get currency types. It requires authentication details and specifies the method 'FEParamGetTiposMonedas'. ```json { "environment": "dev", "method": "FEParamGetTiposMonedas", "wsid": "wsfe", "params": { "Auth" : { "Token": "{{token}}", "Sign": "{{sign}}", "Cuit": "20409378472" } } } ``` -------------------------------- ### Crear Siguiente Comprobante con CAE (.NET) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica.md Utiliza el método `CreateNextVoucherAsync` para asignar un CAE al siguiente comprobante. Devuelve el CAE y su fecha de vencimiento. ```csharp var res = await afip.ElectronicBilling.CreateNextVoucherAsync(data); res["CAE"]; //CAE asignado el comprobante res["CAEFchVto"]; //Fecha de vencimiento del CAE (yyyy-mm-dd) res["voucher_number"]; //Número asignado al comprobante ``` -------------------------------- ### API Request for Aliquot Types Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica.md This is an example of an API request to get aliquot types. It requires authentication details and specifies the method 'FEParamGetTiposIva'. ```json { "environment": "dev", "method": "FEParamGetTiposIva", "wsid": "wsfe", "params": { "Auth" : { "Token": "{{token}}", "Sign": "{{sign}}", "Cuit": "20409378472" } } } ``` -------------------------------- ### Instantiate Web Service (Java) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Create an instance of the 'wscpe' web service for Java. ```java AfipWebService ws = afip.webService("wscpe"); ``` -------------------------------- ### Instantiate Web Service (PHP) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Create an instance of the 'wscpe' web service for PHP. ```php $ws = $afip->WebService('wscpe'); ``` -------------------------------- ### API Request for Get CUIT by DNI Source: https://docs.afipsdk.com/siguientes-pasos/web-services/padron-alcance-13.md Example JSON payload for the API endpoint to retrieve CUIT from DNI using the 'getIdPersonaListByDocumento' method. ```json { "environment": "dev", "method": "getIdPersonaListByDocumento", "wsid": "ws_sr_padron_a13", "params": { "token": "{{token}}", "sign": "{{sign}}", "cuitRepresentada": "20409378472", "documento" : 11111111 } } ``` -------------------------------- ### Crear Comprobante y Obtener CAE en C# Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica.md Utiliza el método `CreateVoucherAsync` para registrar un comprobante y obtener el CAE y su fecha de vencimiento. El parámetro `returnFullResponse` controla si se devuelve la respuesta completa del web service. Los detalles del comprobante se pasan como un diccionario. ```csharp // Devolver respuesta completa del web service bool returnFullResponse = false; // Info del comprobante var data = new Dictionary { ["CantReg"] = 1, // Cantidad de comprobantes a registrar ["PtoVta"] = 1, // Punto de venta ["CbteTipo"] = 6, // Tipo de comprobante (ver tipos disponibles) ["Concepto"] = 1, // Concepto del Comprobante: (1)Productos, (2)Servicios, (3)Productos y Servicios ["DocTipo"] = 99, // Tipo de documento del comprador (99 consumidor final, ver tipos disponibles) ["DocNro"] = 0, // Número de documento del comprador (0 consumidor final) ["CbteDesde"] = 1, // Número de comprobante o numero del primer comprobante en caso de ser mas de uno ["CbteHasta"] = 1, // Número de comprobante o numero del último comprobante en caso de ser mas de uno ["CbteFch"] = int.Parse(DateTime.UtcNow.ToString("yyyyMMdd")), // (Opcional) Fecha del comprobante (yyyymmdd) o fecha actual si es nulo ["ImpTotal"] = 121, // Importe total del comprobante ["ImpTotConc"] = 0, // Importe neto no gravado ["ImpNeto"] = 100, // Importe neto gravado ["ImpOpEx"] = 0, // Importe exento de IVA ["ImpIVA"] = 21, // Importe total de IVA ["ImpTrib"] = 0, // Importe total de tributos ["MonId"] = "PES", // Tipo de moneda usada en el comprobante (ver tipos disponibles)('PES' para pesos argentinos) ["MonCotiz"] = 1, // Cotización de la moneda usada (1 para pesos argentinos) ["CondicionIVAReceptorId"] = 5, // Condición frente al IVA del receptor ["Iva"] = new[] // (Opcional) Alícuotas asociadas al comprobante { new Dictionary { ["Id"] = 5, // Id del tipo de IVA (5 para 21%)(ver tipos disponibles) ["BaseImp"] = 100, // Base imponible ["Importe"] = 21 // Importe } } }; var res = await afip.ElectronicBilling.CreateVoucherAsync(data, returnFullResponse); res["CAE"]; //CAE asignado el comprobante res["CAEFchVto"]; //Fecha de vencimiento del CAE (yyyy-mm-dd) ``` -------------------------------- ### API Request for Get Taxpayer Details Source: https://docs.afipsdk.com/siguientes-pasos/web-services/padron-alcance-13.md Example JSON payload for the API endpoint to retrieve taxpayer details using the 'getPersona' method. ```json { "environment": "dev", "method": "getPersona", "wsid": "ws_sr_padron_a13", "params": { "token": "{{token}}", "sign": "{{sign}}", "cuitRepresentada": "20409378472", "idPersona" : 20111111111 } } ``` -------------------------------- ### Instantiate Web Service (Node.js) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Create an instance of the 'wscpe' web service for Node.js. ```javascript const ws = afip.WebService('wscpe'); ``` -------------------------------- ### Ruby Web Service Request Example Source: https://docs.afipsdk.com/siguientes-pasos/web-services/otro-web-service.md This Ruby snippet demonstrates how to call an AFIP web service, specifically 'wsct', to get the last authorized document. It covers obtaining an authorization token and handling errors. ```ruby # Nombre del web service. # # El nombre por el cual se llama al web service en AFIP. # Esto lo podes encontrar en el manual correspondiente. # Por ej. el de factura electronica se llama "wsfe", el de # comprobantes T se llama "wsct" servicio = "wsct" # Creamos el web service genericWebService = afip.webService(servicio) # Este es un ejemplo de como utilizar el wsct para # obtener el ultimo comprobante autorizado # # Aqui veras como obtener un Token Authorizataion # para el web service que acabamos de crear y como # ejecutar un request basico # Obtenemos el Token Authorizataion ta = genericWebService.getTokenAuthorization # Preparamos los datos que nos pide el web service # # Este ejemplo es especifico para el wsct. En el manual # del web service que quieras utilizar encontraras que # datos requiere cada metodo data = { "authRequest": { "token": ta["token"], "sign": ta["sign"], "cuitRepresentada": afip.CUIT }, "codigoTipoComprobante": 195, "numeroPuntoVenta": 1 } begin # Ejecutamos la request al web service # # consultarUltimoComprobanteAutorizado es un metodo # de wsct, esto debes cambiarlo por el metodo que # quieras utilizar result = genericWebService.executeRequest("consultarUltimoComprobanteAutorizado", data) # Mostramos el resultado puts result unless result["arrayErrores"] # Checkeamos si devolvio error en el resultado. # # arrayErrores es especifico de este web service. # Esto deberas adaptarlo al web service que estes integrando err = result["arrayErrores"]["codigoDescripcion"].is_a?(Array) ? result["arrayErrores"]["codigoDescripcion"][0] : result["arrayErrores"]["codigoDescripcion"] raise "(#{err["codigo"]}) #{err["descripcion"]}" rescue => e # Mostramos el error puts e end ``` -------------------------------- ### Install Afip SDK via RubyGems Source: https://docs.afipsdk.com/integracion/ruby.md Use this command to install the Afip SDK gem directly from RubyGems. ```bash gem install afip.rb ``` -------------------------------- ### Instantiate Web Service (Ruby) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Create an instance of the 'wscpe' web service for Ruby. ```ruby ws = afip.webService("wscpe") ``` -------------------------------- ### Initialize WSREMECARNE Web Service Client Source: https://docs.afipsdk.com/siguientes-pasos/web-services/remito-carnico.md Instantiate the 'wsremcarne' web service client. This is the first step before making any requests to the AFIP Remito Cárnico service. ```js const ws = afip.WebService('wsremcarne'); ``` ```php $ws = $afip->WebService('wsremcarne'); ``` ```ruby ws = afip.webService("wsremcarne") ``` ```python ws = afip.webService("wsremcarne") ``` ```csharp AfipWebService ws = afip.WebService("wsremcarne"); ``` ```java AfipWebService ws = afip.webService("wsremcarne"); ``` -------------------------------- ### Install Supabase CLI and Create Edge Function Source: https://docs.afipsdk.com/integracion/serverless/supabase-edge-functions.md Install the Supabase CLI and create a new Edge Function named 'afipSDK' in your Supabase project. ```bash supabase functions new afipSDK ``` -------------------------------- ### Generar Código QR con Python Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica/codigo-qr.md La librería 'segno' es adecuada para la generación de códigos QR en Python. Visita el enlace para ver cómo instalarla y utilizarla. ```bash pip install segno ``` -------------------------------- ### Get Server Status in .NET Source: https://docs.afipsdk.com/siguientes-pasos/web-services/padron-de-constancia-de-inscripcion.md Use this asynchronous C# snippet to get the server status. The ARCA service might report 'all good' even when there are failures. ```csharp var serverStatus = await afip.RegisterInscriptionProof.GetServerStatusAsync(); Console.WriteLine('Este es el estado del servidor:'); Console.WriteLine(JsonSerializer.Serialize(serverStatus)); ``` -------------------------------- ### API Request Example for ComprobanteConstatar Source: https://docs.afipsdk.com/siguientes-pasos/web-services/constatacion-de-comprobantes.md This is an example JSON payload for making a 'ComprobanteConstatar' request to the web service API. It includes authentication details and the specific parameters for the request. ```json { "environment": "dev", "method": "ComprobanteConstatar", "wsid": "wscdc", "params": { "Auth": { "Token": "{{token}}", "Sign": "{{sign}}", "Cuit": "20409378472" }, "CmpReq": { "CbteModo": "CAE", "CuitEmisor": 20000000001, "PtoVta": 1, "CbteTipo": 1, "CbteNro": 2, "CbteFch": 20101014, "ImpTotal": 300.8, "CodAutorizacion": "60428000005029", "DocTipoReceptor": "80", "DocNroReceptor": "300000000007" } } } ``` -------------------------------- ### Generar Código QR con Node.js Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica/codigo-qr.md Utiliza la librería 'qrcode' para generar imágenes de códigos QR. Asegúrate de tenerla instalada en tu proyecto Node.js. ```bash npm install qrcode ``` -------------------------------- ### Install Afip SDK and Create Cloudflare Worker Source: https://docs.afipsdk.com/integracion/serverless/cloudflare-workers.md Use npm to create a new Cloudflare worker project and install the Afip SDK. This sets up the basic project structure. ```bash npm create cloudflare@latest afipsdk cd afipsdk npm install @afipsdk/afip.js ``` -------------------------------- ### Prepare Data for consultarUltNroOrden (Python) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/carta-de-porte-electronica.md Prepare authentication and request data for the 'consultarUltNroOrden' method in Python. Requires obtaining a Token Authorization first. ```python # Obtenemos el TA ta = ws.getTokenAuthorization() # Preparamos los datos data = { "auth": { "token": ta["token"], "sign": ta["sign"], "cuitRepresentada": afip.CUIT }, "solicitud": { "sucursal": 195, "tipoCPE": 1 } } ``` -------------------------------- ### Initialize wsfecred Web Service Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-mipyme.md Instantiate the 'wsfecred' web service for Factura MiPyME operations. This is the first step before making any API calls. ```js const ws = afip.WebService('wsfecred'); ``` ```php $ws = $afip->WebService('wsfecred'); ``` ```ruby ws = afip.webService("wsfecred") ``` ```python ws = afip.webService("wsfecred") ``` ```csharp AfipWebService ws = afip.WebService("wsfecred"); ``` ```java AfipWebService ws = afip.webService("wsfecred"); ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica/crear-pdf.md To get information not directly on the page, make an HTTP GET request to the page URL with an 'ask' query parameter. The question should be specific and in natural language. ```http GET https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica/crear-pdf.md?ask= ``` -------------------------------- ### Configure AFIP SDK for Production (Python) Source: https://docs.afipsdk.com/siguientes-pasos/ir-a-produccion.md Initialize the AFIP SDK in Python for production. Load your production certificate and key from files. ```python # Certificado (Puede estar guardado en archivos, DB, etc) cert = open("./certificado.crt").read() # Key (Puede estar guardado en archivos, DB, etc) key = open("./key.key").read() afip = Afip({ "CUIT": 20111111112, "cert": cert, "key": key, "access_token": "access_token obtenido en https://app.afipsdk.com/", "production": True }) ``` -------------------------------- ### API Call Example Source: https://docs.afipsdk.com/siguientes-pasos/web-services/otro-web-service.md This snippet demonstrates how to make a POST request to the AFIP API to invoke a web service method. It includes the endpoint, method, and an example request body. ```APIDOC ## POST https://app.afipsdk.com/api/v1/afip/requests ### Description This endpoint allows you to make requests to various AFIP web services by specifying the method, web service ID, and parameters. ### Method POST ### Endpoint `https://app.afipsdk.com/api/v1/afip/requests` ### Parameters #### Request Body - **environment** (string) - Required - The environment to use (e.g., 'dev'). - **method** (string) - Required - The name of the web service method to call. - **wsid** (string) - Required - The ID of the web service (e.g., 'wsct'). - **params** (object) - Required - An object containing the parameters required by the specified web service method. - **authRequest** (object) - Required - Authentication details. - **token** (string) - Required - The authorization token. - **sign** (string) - Required - The signature for the token. - **cuitRepresentada** (string) - Required - The CUIT of the represented entity. - **codigoTipoComprobante** (integer) - Optional - The type code of the voucher. - **numeroPuntoVenta** (integer) - Optional - The point of sale number. ### Request Example ```json { "environment": "dev", "method": "consultarUltimoComprobanteAutorizado", "wsid": "wsct", "params": { "authRequest": { "token": "{{token}}", "sign": "{{sign}}", "cuitRepresentada": "20409378472" }, "codigoTipoComprobante": 195, "numeroPuntoVenta": 1 } } ``` ``` -------------------------------- ### Obtener Información de Comprobante (C#) Source: https://docs.afipsdk.com/siguientes-pasos/web-services/factura-electronica.md Utiliza este código C# para consultar un comprobante electrónico. El método asíncrono GetVoucherInfoAsync es el encargado de la consulta. ```csharp // Numero de comprobante int numeroDeComprobante = 1; // Numero de punto de venta int puntoDeVenta = 1; // Tipo de comprobante int tipoDeComprobante = 6; // 6 = Factura B var voucherInfo = await afip.ElectronicBilling.GetVoucherInfoAsync(numeroDeComprobante, puntoDeVenta, tipoDeComprobante); if (voucherInfo == null) { Console.WriteLine("El comprobante no existe"); } else { Console.WriteLine("Esta es la información del comprobante:"); Console.WriteLine(JsonSerializer.Serialize(voucherInfo)); } ``` -------------------------------- ### API Request Example for Tourism Receipts Source: https://docs.afipsdk.com/siguientes-pasos/web-services/comprobantes-de-turismo.md Example JSON payload for making a POST request to the API endpoint to consult the last authorized tourism receipt. Includes authentication and receipt details. ```json { "environment": "dev", "method": "consultarUltimoComprobanteAutorizado", "wsid": "wsct", "params": { "authRequest": { "token": "{{token}}", "sign": "{{sign}}", "cuitRepresentada": "20409378472" }, "codigoTipoComprobante": 195, "numeroPuntoVenta": 1 } } ```