I have made a C#-a project that tries to connect to my Business Central cloud sandbox.
I made an extension for Business Central with a new code unit that has a function I call "MHSTest." It only sends back a text.
I set up the service reference that connects to the SOAP URL in Business Central in Visual Studio. So Visual Studio shows me the name of my function, "MHSTest."
Visual Studio gives me an error when I type this because it tries to connect anonymously:
var client = new MHSTest.CSharpCodeunit_PortClient(); myTextBox.Text = client.MHSTest();
If I instead try the below, I get an error message that says "https" is not valid. "http" has to be there.
string endpoint = "">api.businesscentral.dynamics.com/.../CSharpCodeunit";
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.MaxBufferSize = 999999;
binding.MaxReceivedMessageSize = 999999;
var client = new MHSTest.CSharpCodeunit_PortClient(binding, new EndpointAddress(endpoint));
myTextBox.Text = client.MHSTest();
How do I get data from or set data in Business Central?
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Debitorer_Binding">
<security mode="Transport" />
</binding>
<binding name="Debitorer_Binding1" />
<binding name="CSharpCodeunit_Binding">
<security mode="Transport" />
</binding>
<binding name="CSharpCodeunit_Binding1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="api.businesscentral.dynamics.com/.../2999befa-1255-4304-a79a-67de0e24f090/Sandbox/WS/CRONUS%20Danmark%20A%252FS/Page/Debitorer?tenant=msneua5672t92712555&aid=FIN"
binding="basicHttpBinding" bindingConfiguration="Debitorer_Binding"
contract="BCCustomer.Debitorer_Port" name="Debitorer_Port" />
<endpoint address="api.businesscentral.dynamics.com/.../2999befa-1255-4304-a79a-67de0e24f090/Sandbox/WS/CRONUS%20Danmark%20A%252FS/Codeunit/CSharpCodeunit?tenant=msneua5672t92712555&aid=FIN"
binding="basicHttpBinding" bindingConfiguration="CSharpCodeunit_Binding"
contract="MHSTest.CSharpCodeunit_Port" name="CSharpCodeunit_Port" />
</client>
</system.serviceModel>
</configuration>
Here's a link that may help you.
Step 1. Using Configuration Package
https://yzhums.com/4286/
Step2. Using Open in Excel
https://yzhums.com/18239/
Step 3. Using Excel Buffer
https://yzhums.com/4180/
Step 4. Using XML Port
https://yzhums.com/4809/
Step 5. Using Excel layouts for BC Reports
https://yzhums.com/23873/
Step 6. Using Excel Organization Data Types Gallery
https://yzhums.com/25234/
Step 7. Using Power BI
https://yzhums.com/4637/