web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Error probando APIs de Dynamics 365 Business Central desde ambiente On-premise

(6) ShareShare
ReportReport
Posted on by 24
Buen dia a todos, 
Soy nuevo en la programacion en el Lenguaje AL y estoy intentando probar una API de Business Central v26.0  On-Premise desde Postman.
Mi equipo es independiente, no forma parte a un Dominio.
 
Habilite la linea ODataServicesEnabled: = true, en el archivo CustonSetting.CONFIG
 
Desde Postman:
Metodo: GET
Agrego  la Url:  http://localhost:7048/BC260/api/v2.0/companies
Alternativa Url:  http://localhost:7048/BC260/ODataV4/companies
Ademas, ingreso el modo autenticacion NTLM, con usuario y clave de Windows.
 
Sin embargo me arroja el error 401Unauthorized )
 
Que mas alternativas debo tomar?
 
Gracias por el apoyo.
 
I have the same question (0)
  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at

    Hi ND,

    Thanks for sharing your scenario. Based on your setup and the document you provided, it looks like you're trying to export a payment file from the Payment Journal in Business Central using a custom HSBC BACS format, and you're facing two main issues:

    1. The header row is missing in the exported CSV file
    2. Some required fields (like Batch Name, Sort Code, Account No.) are not appearing in the output

    Here’s how you can address both:


    1. Exporting the Header Row

    Business Central doesn’t include headers by default in CSV exports. However, since you’ve already defined them in the Data Exchange Definition, make sure:

    • The first row is configured as a header in the column mappings.
    • The “Include Header” option is set to Yes in the column definitions.

    This should ensure that the header row appears correctly in the exported file.


    2. Handling Missing Fields

    Fields like Batch Name, 1RG Bank Sort Code, and 1RG Bank Account No. are not part of table 1226 by default. You have two options:

    Option A: Extend Table 1226

    • Create a table extension for Gen. Journal Line or the table used in your export.
    • Add the missing fields and populate them either manually or via AL code during journal entry.

    Option B: Use Related Tables

    • If the data exists in related tables (e.g., Bank Account, Vendor Bank Account), you can retrieve it using a custom codeunit or field mapping logic in the Data Exchange Definition.

    If you plan to implement international payments later, you might also consider including the SWIFT Code now to future-proof your setup.


    3. Optional: Custom Codeunit

    If standard mapping doesn’t allow access to all required fields, a custom codeunit can:

    • Extend the export logic
    • Populate missing fields
    • Format the CSV output as needed

    Expected Output Format

    Here’s an example of what your CSV file should look like:

    Transaction Type,Remitter Batch Reference,Customer Reference,DebtorAgent ClearingMmbrId,Debit Account Number,Beneficiary Name,CreditorAgent ClearingMmbrId,Beneficiary Account Number,Transaction Amount,Payment Currency,Requested Processing Date
    NURG,BATCH001,INV123,123456,12345678,Vendor A,654321,87654321,1000.00,GBP,25/07/2025
    

     

    Best regards,
    Daniele

  • fhernandezve Profile Picture
    24 on at
    Gracias por respuesta.
     
    La intencion de estas APIs,  URL Endpoint:  
     
    -  http://localhost:7048/BC260/api/v2.0/companies
    -  http://localhost:7048/BC260/ODataV4/companies
     
    Es que entregue como resultado, un JSON con la lista de empresas en BC, tanto Nombre como ID_Compania, como lo muestro en el ejempo:
     
    (

    Si la configuración es correcta, Postman debería devolver una respuesta en formato JSON que lista todas las compañías configuradas en tu instancia de Business Central. Cada objeto de compañía incluirá su id (GUID) y su displayName:

    JSON:

    {
        "value": [
            {
                "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                "name": "CRONUS España S.A.",
                "displayName": "CRONUS España S.A.",
                // ... otros detalles de la compañía
            },
            {
                "id": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
                "name": "Mi Empresa Demostración",
                "displayName": "Mi Empresa Demostración",
                // ... otros detalles
            }
        ]
    }

    )
     
    Saludos.
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,136 Super User 2025 Season 2 on at
    El error 401 suele deberse a que NTLM no funciona correctamente fuera de un dominio. Como estás trabajando en un equipo que no pertenece a un dominio, te recomiendo usar autenticación Web Service Access Key en lugar de NTLM.
     
    1. Ve a la ficha del usuario en BC.
     
     
    2. Genera una Web Service Access Key.
     
     
    3. En Postman, usa autenticación básica:
     
    Usuario: el ID del usuario
     
    Contraseña: la Web Service Key generada
     
     
     
     
    Con eso deberías poder acceder a la API sin error 401.
     
    ✅ Mark this answer as verified if it helps you.
     
     
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    Hola,

    El error 401 (Unauthorized) al probar APIs de BC On-Premise desde Postman es bastante común, especialmente en entornos fuera de dominio. Aquí van algunas alternativas y puntos clave para resolverlo:
     

    • Autenticación NTLM vs. Web Service Access Key
      • NTLM puede fallar si el equipo no está en dominio o si el servicio no está configurado para aceptar ese tipo de autenticación.
      • En entornos On-Premise, lo más confiable es usar NavUserPassword con Web Service Access Key como contraseña. Puedes generar esta clave desde la ficha del usuario en BC.
    • Configuración del archivo CustomSettings.config
    • Asegúrate de que estas líneas estén correctamente configuradas:
      • ODataServicesEnabled = true
      • EnableApiServices = true
      • ServicesUseNTLMAuthentication = false (si usas NavUserPassword)
      • ClientServicesCredentialType = NavUserPassword
    • Después de modificar el archivo, reinicia el servicio de BC para aplicar los cambios.
    • Prueba desde Postman
      • Usa el método Basic Auth en lugar de NTLM.
      • Usuario: el nombre de usuario de BC.
      • Contraseña: la Web Service Access Key.
      • URL: http://localhost:7048/BC260/api/v2.0/companies
      • Asegúrate de que el puerto y la instancia coincidan con tu configuración.
    • Verifica el Endpoint
      • Puedes probar primero con http://localhost:7048/BC260/api/v2.0/ para ver si responde.
      • Si usas múltiples compañías, añade el parámetro ?company=CRONUS%20ES (o el nombre de tu empresa).


    Recursos útiles
    Guía oficial de endpoints para APIs On-Premise
    Solución comunitaria al error 401
    Guía de troubleshooting de APIs REST/OData


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans