Call Codeunit function via Web Service (SOAP) using REST API
Describe the bug
Can not call Codeunit function via Web Service (SOAP) using REST API in cloud service returns an error {"error": {"code": "400","message": "Request data is invalid."}}
To Reproduce
Please call this REST request
GET /v1.0/9c0588e3-9590-4a55-b971-2c8a87643214/sandbox/WS/Company3/Codeunit/ReplicationData HTTP/1.1
Host: api.businesscentral.dynamics.com
Content-Type: text/xml
Authorization: Basic QURNSU46QTZ4R3NzRjUrRjZEdWhVVE8wRFZraTYxcE1LWFdGMHR0cEtRWWxBVng0TT0=
cache-control: no-cache
Postman-Token: 860ca13a-3835-4665-a951-78b2c5afb75b
<?xml version="1.0><ApplyReplicationData xmlns="urn:microsoft-dynamics-schemas/Codeunit/ReplicationData">XMLBOODYTEST</ApplyReplicationData>
Expected behavior
Run and execute function in codeunit

Versions:
-
AL Langauge: 2.0.43900
-
Business Central: AU Dynamics NAV 13.0 (25488)
Blank request work fine but it's run nothing in the database.
GET https://api.businesscentral.dynamics.com/v1.0/9c0588e3-9590-4a55-b971-2c8a87643214/sandbox/WS/Company3/Codeunit/ReplicationData HTTP/1.1
Accept-Encoding: gzip,deflate
Host: api.businesscentral.dynamics.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Authorization: Basic QURNSU46QTZ4R3NzRjUrRjZEdWhVVE8wRFZraTYxcE1LWFdGMHR0cEtRWWxBVng0TT0=
response
<definitions` targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ReplicationData" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:microsoft-dynamics-schemas/codeunit/ReplicationData">
<types>
<schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ReplicationData" xmlns="http://www.w3.org/2001/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="http://schemas.xmlsoap.org/soap/http" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
<operation name="ApplyReplicationData">
<operation soapAction="urn:microsoft-dynamics-schemas/codeunit/ReplicationData:ApplyReplicationData" style="document" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
<input name="ApplyReplicationData">
<body use="literal" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
</input>
<output name="ApplyReplicationData_Result">
<body use="literal" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
</output>
</operation>
</binding>
<service name="ReplicationData">
<port name="ReplicationData_Port" binding="tns:ReplicationData_Binding">
<address location="https://api.businesscentral.dynamics.com/v1.0/9c0588e3-9590-4a55-b971-2c8a87643214/sandbox/WS/Company3/Codeunit/ReplicationData?tenant=msocna4832t36570367&aid=FIN" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
</port>
</service>
</definitions>
If you want to run codeunit using REST API. You can however invoke through bound actions.
Closing this issue as it seems like a runtime issue which is beyond the scope of this repository which is only for issues relateds to the AL compiler in the latest developer preview environment for Dynamics 365 Business Central.
If you are still experiencing this issue, we suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.
To open a support case, you can:
- Open a support request to CSS through the PartnerSource portal
- Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company
If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.