Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Errors trying to update Purchase Order via OData

Posted on by 5

Hoping someone can give me a pointer on this.

Using Business Central Dynamics (hosted by MS), trying to update a Purchase Order custom field via a PUT or PATCH call with OData.

The field I am trying to update is a custom field we have added to the Purchase Order.  I have created the OData server page for the Purchase Order page and the field is present in the results if I do a GET on the page.

The url I am calling is:

api.businesscentral.dynamics.com/.../<tenanat id>/<environment>/ODataV4/Company('<company name>')/PurchaseOrderPage?$filter=No eq '10201'

The json I am passing in is:

{ "Date_Sent_to_Vendor": 2023-05-01}

I have added the following headers to the call:

Content-Type : application/json

If-Match : W/"JzIwOzEzMjk3OTM3ODUwODE3MzIxMzM4MTswMDsn"

I do a GET right before the PATCH call to get the current eTag value to place in the If-Match header.

I am getting the dreaded:

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

I have read all the other threads about making sure the If-Match is there with the current eTag but I am not able to get past this.  All the other examples I have seen are for updating standard fields but nothing on updating a custom field.

Any help or advice would be greatly appreciated!

Thanks!

Bruce

  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: Errors trying to update Purchase Order via OData

    Hope this helps

    [View:https://youtu.be/TSQiE42tDwU:320:240]

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,035 Super User 2024 Season 2 on at
    RE: Errors trying to update Purchase Order via OData

    Hi, Similar to the following question.

       

    But please note that if you publish a standard Purchase Order list, it cannot be edited, and the following error may appear.

    pastedimage1684889901635v2.png

    If you insist on using Odata, I suggest you create a new page.

    Below is a simple example of a Sales Order.

    page 50011 "ZY Sales Orders"
    {
        ApplicationArea = All;
        Caption = 'ZY Sales Orders';
        PageType = List;
        SourceTable = "Sales Header";
        UsageCategory = Lists;
    
        layout
        {
            area(content)
            {
                repeater(General)
                {
                    field("Document Type"; Rec."Document Type")
                    {
                        ToolTip = 'Specifies the value of the Document Type field.';
                    }
                    field("No."; Rec."No.")
                    {
                        ToolTip = 'Specifies the number of the estimate.';
                    }
                    field("Sell-to Customer No."; Rec."Sell-to Customer No.")
                    {
                        ToolTip = 'Specifies the number of the customer associated with the sales return.';
                    }
                    field("Posting Date"; Rec."Posting Date")
                    {
                        ToolTip = 'Specifies the date when the sales document was posted.';
                    }
                    field("Ship-to Code"; Rec."Ship-to Code")
                    {
                        ToolTip = 'Specifies the code for another shipment address than the customer''s own address, which is entered by default.';
                    }
                }
            }
        }
    }
    

    pastedimage1684889925520v3.png

    api.businesscentral.dynamics.com/.../ZYNewSalesOrders(Document_Type='Order',No='101001')

    pastedimage1684889941807v4.png

    pastedimage1684889955771v5.png

    pastedimage1684889977611v6.png

    Hope this can give you some hints.

    Thanks.

    ZHU

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans