Context header
Todas las peticiones a la API de a3innuva Contabilidad deben incluir en el Header
el parámetro Context
. Este parámetro puede contener dos tipos de valor:
none
cuando hagamos peticiones para obtener datos que no están asociados a una empresa.correlationId
cuando queramos obtener datos de un empresa (diario, plan contable, clientes, etc).
Por ejemplo, para obtener la lista de empresas haremos una petición al recurso de companies
informando el valor none
, ya que no estamos accediendo a datos en concreto de una empresa:
- Http
- Curl
- C#
GET /a3innuva-contabilidad/api/companies HTTP/1.1
Host: a3api.wolterskluwer.es
context: none
Ocp-Apim-Subscription-Key: 2kxwf5rb7ffb65dd5
Authorization: Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...
Content-Type: application/json
curl --location 'https://a3api.wolterskluwer.es/a3innuva-contabilidad/api/companies' \
--header 'context: none' \
--header 'Ocp-Apim-Subscription-Key: 2kxwf5rb7ffb65dd5' \
--header 'Authorization: Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...' \
--header 'Content-Type: application/json'
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://a3api.wolterskluwer.es/a3innuva-contabilidad/api/companies");
request.Headers.Add("context", "none");
request.Headers.Add("Ocp-Apim-Subscription-Key", "2kxwf5rb7ffb65dd5");
request.Headers.Add("Authorization", "Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...");
var content = new StringContent(string.Empty);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Nos devolverá la relación de empresas de a3innuva Contabilidad:
[
{
"vatName": "EMPRESA PRUEBAS S.A.",
"vatNumber": "H41585142",
"state": "Enabled",
"chartOfAccountId": 1,
"accountLength": 10,
"correlationId": "b1f14e5a-ed3b-45ec-b555-6cac1d2396c7",
"version": "2022-09-20T07:36:30.9691227Z",
"sequenceVersion": "637992561909691227"
},
{
"vatName": "EMPRESA PRUEBAS, S.L. ",
"vatNumber": "04544545K",
"state": "Enabled",
"chartOfAccountId": 1,
"accountLength": 10,
"correlationId": "A3TFR:061602:CM:98d52a37-3659-4d01-a526-750888feb5d9",
"version": "2023-04-24T13:35:34.4231448Z",
"sequenceVersion": "638179401344231450"
}
]
Si ahora queremos obtener las cuentas del plan contable de la "EMPRESA PRUEBAS, S.L.", realizaríamos la siguiente petición:
- Http
- Curl
- C#
GET /a3innuva-contabilidad/api/accounts?pageNumber=1&pageSize=50 HTTP/1.1
Host: a3api.wolterskluwer.es
context: {"clientId": "A3TFR:061602:CM:98d52a37-3659-4d01-a526-750888feb5d9"}
Ocp-Apim-Subscription-Key: 2kxwf5rb7ffb65dd5
Authorization: Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...
Content-Type: application/json
curl --location 'https://a3api.wolterskluwer.es/a3innuva-contabilidad/api/accounts?pageNumber=1&pageSize=50' \
--header 'context: {"clientId": "A3TFR:061602:CM:98d52a37-3659-4d01-a526-750888feb5d9"}' \
--header 'Ocp-Apim-Subscription-Key: 2kxwf5rb7ffb65dd5' \
--header 'Authorization: Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...' \
--header 'Content-Type: application/json'
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://a3api.wolterskluwer.es/a3innuva-contabilidad/api/accounts?pageNumber=1&pageSize=50");
request.Headers.Add("context", "{"clientId": "A3TFR:061602:CM:98d52a37-3659-4d01-a526-750888feb5d9"}");
request.Headers.Add("Ocp-Apim-Subscription-Key", "2kxwf5rb7ffb65dd5");
request.Headers.Add("Authorization", "Bearer eyIkaWQiOiIxIiwidHlwIjoiSld...");
var content = new StringContent(string.Empty);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
El valor del campo context
es case-sensitive y tiene formato de cadena json. El nombre del campo tendrá el valor fijo clientId
y el valor será el correlationId
de la empresa.
El resultado de la petición será la relación de cuentas contables de la empresa:
[
{
"correlationId": "8bc0fcaf-1d19-4842-9a7e-90d87e3c8fb9",
"code": "1000000000",
"description": "Capital social",
"state": "Enabled",
"version": "2023-04-24T13:46:59.1472528Z",
"sequenceVersion": "638179408191472526"
},
{
"correlationId": "",
"code": "1010000000",
"description": "Fondo social",
"state": "Template",
"version": "0001-01-01T00:00:00Z",
"sequenceVersion": "0"
},
...
]