Tuesday, May 22, 2018

Sitecore Experience Commerce - Service Proxy execute compilation error

When attempting to call my custom API in the commerce engine, I was getting a compilation error on the Execute method of a service proxy call.
Cannot convert from 'Microsoft.OData.Client.DataServiceActionQuerySingle<MyModel>' to 'Microsoft.OData.Client.DataServiceActionQuery<MyModel>' 
At first I thought it was a duplicate method across both the shops and ops proxy. But as it turns out, I was expecting a return type of collection and the proxy was expecting a single return object (hence the single at the end of DataServiceActionQuerySingle).

This was resolved by going back into the commerce engine where I configured the API and changing the return type from:
configuration.ReturnsFromEntitySet<ExtendedPricingDetail>("Api");
To:
 configuration.ReturnsCollectionFromEntitySet<ExtendedPricingDetail>("Api");
Then a re-generation of the service proxy and all was working as expected.

No comments:

Post a Comment