ServiceStack is being used to provide web services that expose OData data, connecting to our Dynamics365 hosted environment. The services themselves are working, but I have a nagging error in our main HTML page that I’m looking for advice on.
The HTML code is relatively simple and was based on the information presented here: https://docs.servicestack.net/typescript-add-servicestack-reference#install. Here’s the relevant snippet:
...
<body>
<h2>Dynamics Web Services</h2>
<div id="result"></div>
<script src="https://unpkg.com/@servicestack/client/dist/servicestack-client.min.js"></script>
<script src="/js/require.js"></script>
<script src="/js/servicestack-client.js"></script>
<script src="/types/js"></script>
<script>
var { JsonServiceClient, GetVersion } = exports;
var client = new JsonServiceClient();
function callGetVersion() {
client.api(new GetVersion())
.then(function(r) {
document.getElementById('result').innerHTML = r.status;
});
}
callGetVersion();
</script>
...
The GetVersion service simply returns a string that includes the current assembly information and a link to the metadata/Swagger.
When the page is rendered, the generated JS contains an error that prevents the call to the web service from running correctly. I can see that the types/js file is getting regenerated each time as the header timestamp gets updated.
For reference, the Visual Studio Extension “OData Connected Service” was used to generate the Reference.cs that defines all the various classes that represent the OData endpoints (https://github.com/odata/ODataConnectedService).
I’ve tested this type of approach with a similar project that doesn’t utilize OData objects in the services and that project works as expected, the service is called and no JS error occur.
I’m unsure of how to proceed or what my options are to resolve this error.