Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Bound action on custom API - getting BadRequest_NotFound

Posted on by 5
Hi, I hope this question has not been answered before as I have searched and read my eyes dry for information.

I have a page, Pagetype = API, and i want to call the procedure Test which i have given the [ServiceEnabled
attribute.
The EntitySetName is 'customers'.

I am using this link format and i have been trying with GET and POST but it doesn't make a difference.

https://api.businesscentral.dynamics.com/v2.0/tenant/Sandbox/api/APIPublisher/APIGroup/APIVersion/companies(GUID)/customers(GUID)/Nav.Test


I have looked into the Microsoft V2 API source, example Page 30037 APIV2 - Sales Quotes where the MakeOrder service is exposed and that works fine.

By mentioning that, my problem is that i want to make an order from a quote, but i also want to have the new order number returned but i only get an empty 204 response.

Looking into the native makeOrder API, this is the last code that is executed:

ActionContext.AddEntityKey(FieldNo(Id), SalesHeader.SystemId);
ActionContext.SetResultCode(WebServiceActionResultCode::Deleted);


Our sandbox environment is on version 19 .

Thank you for your time and help

Kindly
Andreas
Categories:
  • Wishdale Profile Picture
    Wishdale 5 on at
    RE: Bound action on custom API - getting BadRequest_NotFound

    Thank you!

  • Suggested answer
    Wishdale Profile Picture
    Wishdale 5 on at
    RE: Bound action on custom API - getting BadRequest_NotFound

    I resolved it

    Apparently the bound action is renamed with initial lowercasing, MyProcedure becomes myProcedure (Look it up with $metadata#).

    And the procedure, when called, needs to be prepended with Microsoft.NAV, eg: Microsoft.NAV.myFunction

    Also if you want return values, only primitives seems to be allowed and you can't use the standard procedure pattern;
    "procedure MyProcedure(var ActionContext: WebServiceActionContext)", as the procedure will not be made available if one gives it a return value.

    One needs to give it 0 or more parameters like
    procedure MyProcedure(myParameter: Text): Decimal
    var
        ActionContext: WebServiceActionContext
    begin
     exit(0);
    end;
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 70,124 Super User 2024 Season 2 on at
    RE: Bound action on custom API - getting BadRequest_NotFound

    Hi, I recently added a new Action to Power Automate, hope this will give you some inspiration.

    https://yzhums.com/20111/

    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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,564 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans