web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Business Central forum

Using OData, can't access exposed method in Codeunit

(0) ShareShare
ReportReport
Posted on by 35

Hi,

I have a situation with using OData in Business Central (CU3). I tried this example provided by Microsoft: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-creating-and-interacting-with-odatav4-bound-action

Everything is ok, the code is with no errors but when I tried to reach the exposed method "Copy" with URL as mentioned in the post I can't reach it. My question is how to reach this kind of methods with API? What am I missing in Microsoft's example?

My request looks like that, the same as in example but it doesn't work: {baseurl}/ODataV4/Company('CRONUS')/SalesInvoiceCopy('S-ORD101001')/NAV.Copy

I get this error:  {"error":{"code":"BadRequest_NotFound","message":"Bad Request - Error in query syntax."}}

The only request which gives some positive result are: 

{baseurl}/ODataV4/Company('Konverzija')/SalesInvoiceCopy/NAV.SalesInvoiceCopy (return list of all invoices)

{baseurl}/ODataV4/Company('Konverzija')/SalesInvoiceCopy (return list of all invoices)

This one also works: 

{baseurl}/ODataV4/Company('CRONUS')

{baseurl}/ODataV4/$metadata

 

Can anyone please show me how to make this request working? I would like to do the same as in Microsoft's example, I would like to reach a specific Invoice and perform a "Copy" action. If anyone can give me some pieces of information or link to some useful webpages where I could see more (real) examples of OData API I would be really happy. 

I tried many combinations to combine request but no luck. 

I hope someone can help me. 

Thank you!

Categories:
I have the same question (0)

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans