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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Fields not exposed via API

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I am programmatically creating Sales Invoices through API. But can't see a lot of fields exposed through API

for instance "Payment Method Code"

Is there a way to update this field Programmatically?

Thanks and Regards,

Amit

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    If the required fields is not available in the standard api, you can export your custom api.

    Follow below link

    learn.microsoft.com/.../devenv-develop-custom-api

  • AmitVerma102 Profile Picture
    5 on at

    Thanks Nitin,

    Do you have any example, how to do this in C#?

    Regards,

    Amit

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    API page creation I asked you on BC AL code side, so not sure how you can achieve it on C#

    Thanks.

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,187 Moderator on at

    If you need a field available in he API that you do not find there you will have to create a custom API.

    The custom API needs to be created on the BC side before you can use it from C#.

    And you are correct that payment method is not a part of the standard API.

  • Suggested answer
    YUN ZHU Profile Picture
    100,602 Super User 2026 Season 1 on at

    Hi, hope the following helps.

    Can we extend standard APIs? – Download Standard Source Code for APIs
    https://yzhums.com/20960/

    Thanks.

    ZHU

  • AmitVerma102 Profile Picture
    5 on at

    Hi Inge,

    Thanks for guidance. I exposed the field and am getting List of Sales Invoices now. I want to update Payment Method on one of them so I tried applying filter like

    api.businesscentral.dynamics.com/.../SalesInvoiceExtensions(No='S-INV000111)

    but getting Not Found

    then I tried

    api.businesscentral.dynamics.com/.../SalesInvoiceExtensions?$filter=No eq 'S-INV000111'

    this works but again it returns Collection with 1 item and I get following error on PATCH operation

    PATCH requests for '' of EdmType 'Collection' are not allowed within Dynamics 365 Business Central OData web services

    How can I perform update operation here please?

    Thanks and Regards,

    Amit

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,187 Moderator on at

    I think you have to use the Id field when you want the patch the sales order - here is an example from the standard API

    PATCH businesscentralPrefix/companies({id})/salesOrders({id})

    Does that make sense?

    learn.microsoft.com/.../dynamics_salesorder_update

  • AmitVerma102 Profile Picture
    5 on at

    Hi,

    It does and actually should work, but when I fetch the whole list it works fine as listed below.

    When I use Id in result listed below and call it with Id. HttpClient returns not found.

    pastedimage1683383160683v1.png

    My API Page code looks like this

    page 50149 "Sales Header Extension"
    {
        PageType = API;

        APIVersion = 'v1.0';
        APIPublisher = 'xxxxx';
        APIGroup = 'xxxext;

        EntityCaption = 'SalesInvoiceHeaderExt';
        EntitySetCaption = 'Extension';
        EntityName = 'sinvext';
        EntitySetName = 'headerext';

        SourceTable = "Sales Header";

        Extensible = true;
        DelayedInsert = true;

        layout
        {
            area(content)
            {
                repeater(Group)
                {
                    field(id; Rec.SystemId)
                    {
                        Caption = 'Id';
                        Editable = false;
                    }
                    field(PaymentMethodCode; Rec."Payment Method Code")
                    {
                        Caption = 'Payment Method Code';
                    }
                }
            }
        }
    }
  • Suggested answer
    AmitVerma102 Profile Picture
    5 on at

    Thanks everyone for all the help. This is now resolved.

    Missing part was 

    ODataKeyFields = SystemId;
    This is the field on which Webservice search works.
    Regards,
    Amit

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,419 User Group Leader on at
    Hi,
     
     
    You Cannot customize standard API Endpoint.
     
    Regards,
    Saurav Dhyani

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,036 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,179 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 828

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans