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

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,708 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,708 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
    Inge M. Bruvik Profile Picture
    1,111 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
    95,679 Super User 2025 Season 2 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
    Inge M. Bruvik Profile Picture
    1,111 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,380 Super User 2025 Season 2 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

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 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans