hougaard / Simple-Object-Designer

Issue tracking for the Simple Object Designer for Business Central
7 stars 0 forks source link

How to use the Business Logic exposed as API #308

Open asubi opened 12 months ago

asubi commented 12 months ago

I am testing exposing the Purch Post.
Question: What is the difference between your Purchase Post and Standard BC Bound action on Purchase Orders? Is it possible to only post receive vs receive and invoice?

Issue: I cannot seem to use the endpoint. I can see the endpoint as: https://api.businesscentral.dynamics.com/v2.0/{Tenant}/{Environment}/api/hougaard/SCA/v2.0/companies({id})/purch_Post_OnRuns

Can you provide the usage of the call? Is it a GET or a POST?

Is it like the standard BC API bound action like this? https://://api/v2.0/companies({id})/purchaseOrders({id})/Microsoft.NAV.receiveAndInvoice

I am trying this and it is not working: POST https://api.businesscentral.dynamics.com/v2.0/{{Tenant}}/{{Environment}}/api/hougaard/SCA/v2.0/companies({{CompanyNT}})/purch__post_onruns({id})

I get error: "code": "BadRequest_MethodNotAllowed", "message": "'POST' requests for 'purch__post_onruns' of EdmType 'Entity' are not allowed within Dynamics 365 Business Central OData web services."

When I try a GET it returns: "code": "BadRequest_ResourceNotFound", "message": "Resource not found for the segment 'purch__post_onruns'.

Thanks!

hougaard commented 12 months ago

It's someward more complicated, and I'm behind on documenting how to do this, but this is the short version:

  1. Create a new record in the purch_Post_OnRuns entity (POST)
  2. Call the bound action on the record created in step 1 (With the Purchase header primary key fields as parameters) (POST)
  3. Retrieve the record from step 1 to see the result (GET)

What I usually do, is creating this in Power Automate as a flow, and the go behind each call to see the syntax.

hougaard commented 12 months ago

But yes, it's possible to only receive with this.