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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Calling Codeunit Web Service (SOAP) using REST API

(0) ShareShare
ReportReport
Posted on by

Hello,

Could you advise me how call the function in the codeunit via REST API?

BC the Soap services URL format is changed from NAV Soap services URL to REST API.
my request now looks like this:

GET /v1.0/9c0588e3-9590-4a55-b971-2c8a87643214/sandbox/WS/Company3/Codeunit/ReplicationData? HTTP/1.1
Host: api.businesscentral.dynamics.com
Authorization: Basic QURNSU46.....

The BC sent the response

<definitions targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ReplicationData" xmlns="schemas.xmlsoap.org/wsdl" xmlns:tns="urn:microsoft-dynamics-schemas/codeunit/ReplicationData">
    <types>
        <schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ReplicationData" xmlns="www.w3.org/.../XMLSchema">
            <element name="ApplyReplicationData">
                <complexType>
                    <sequence/>
                </complexType>
            </element>
            <element name="ApplyReplicationData_Result">
                <complexType>
                    <sequence/>
                </complexType>
            </element>
        </schema>
    </types>
    <message name="ApplyReplicationData">
        <part name="parameters" element="tns:ApplyReplicationData"/>
    </message>
    <message name="ApplyReplicationData_Result">
        <part name="parameters" element="tns:ApplyReplicationData_Result"/>
    </message>
    <portType name="ReplicationData_Port">
        <operation name="ApplyReplicationData">
            <input name="ApplyReplicationData" message="tns:ApplyReplicationData"/>
            <output name="ApplyReplicationData_Result" message="tns:ApplyReplicationData_Result"/>
        </operation>
    </portType>
    <binding name="ReplicationData_Binding" type="tns:ReplicationData_Port">
        <binding transport="schemas.xmlsoap.org/.../http" xmlns="schemas.xmlsoap.org/.../soap"/>
        <operation name="ApplyReplicationData">
            <operation soapAction="urn:microsoft-dynamics-schemas/codeunit/ReplicationData:ApplyReplicationData" style='document' xmlns='schemas.xmlsoap.org/.../soap"/>
            <input name="ApplyReplicationData">
                <body use="literal" xmlns="schemas.xmlsoap.org/.../soap"/>
            </input>
            <output name="ApplyReplicationData_Result">
                <body use="literal" xmlns="schemas.xmlsoap.org/.../soap"/>
            </output>
        </operation>
    </binding>
    <service name="ReplicationData">
        <port name="ReplicationData_Port" binding="tns:ReplicationData_Binding">
            <address location="api.businesscentral.dynamics.com/.../ReplicationData;amp;tenant=msocna4832t36570367&amp;aid=FIN" xmlns="schemas.xmlsoap.org/.../soap"/>
        </port>
    </service>
</definitions>

But what the parameter is responsible for calling a specific function is not clear to me.

Categories:
I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Gregory,

    Have a look at the documentation for the API, it will define all the scenario's and provides sample code:

    docs.microsoft.com/.../fin-graph

  • GregoryA Profile Picture
    on at

    Sorry, but in this documentation there is no information about calling codeunits function, there there are only standard API for GET/MODIFY data

  • Community Member Profile Picture
    on at

    Hi Gregory,

    You'll have to publish your custom code either as a Webservice endpoint or an API page.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can call a custom code via API by using Bound Actions. More info here:

    docs.microsoft.com/.../devenv-creating-and-interacting-with-odatav4-bound-action

  • GregoryA Profile Picture
    on at

    Hi Dave,

    yes it  published as SOAP WebService

    _21043D0438043C043E043A04_.JPG

  • GregoryA Profile Picture
    on at

    Hi Stefano,

    Is 'Bound Actions' work with Soap web service? It seems to be feature only available for ODATA web servises.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Gregory,

    The Bound Actions works for both Odata and Soap Web Services (just check when you publish your page as web service it generates an OData URL and a SOAP URL). if you like SOAP, use the SOAP URL.

    -------------

    Best Regards,

  • isabtogumon Profile Picture
    99 on at
    Hi Gregory, 

    Can you explain in detail how you solved this problem? I'm currently stuck on this
  • Nalin.karu Profile Picture
    120 on at

    With unbound actions, you can call codeunit via API REST web services. please check the following link.

    docs.microsoft.com/.../devenv-creating-and-interacting-with-odatav4-unbound-action

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 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