Skip to main content

Notifications

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

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,316 Super User 2025 Season 1 on at
    Fields not exposed via API
    Hi,
     
     
    You Cannot customize standard API Endpoint.
     
    Regards,
    Saurav Dhyani
  • Suggested answer
    AmitVerma102 Profile Picture
    5 on at
    RE: Fields not exposed via API

    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

  • AmitVerma102 Profile Picture
    5 on at
    RE: Fields not exposed via API

    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
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: Fields not exposed via API

    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
    RE: Fields not exposed via API

    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
    YUN ZHU Profile Picture
    84,274 Super User 2025 Season 1 on at
    RE: Fields not exposed via API

    Hi, hope the following helps.

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

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: Fields not exposed via API

    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
    Nitin Verma Profile Picture
    21,565 Moderator on at
    RE: Fields not exposed via API

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

    Thanks.

  • AmitVerma102 Profile Picture
    5 on at
    RE: Fields not exposed via API

    Thanks Nitin,

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

    Regards,

    Amit

  • Suggested answer
    Nitin Verma Profile Picture
    21,565 Moderator on at
    RE: Fields not exposed via API

    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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans