I am in the middle of writing a plugin to get product recommendations from a particular user to display on the XP Storefront side. I wrote my plugin to return a RecommendationList (which inherits from CommerceEntity). Inside the ConfigureServiceApiBlock, I setup the configuration like so:

var getRecommendationsAction = modelBuilder.Function("GetRecommendations");

and, in the ApiController, I set up the Recommendations call like so:

    public async Task<IActionResult> GetRecommendations(string customerId)
        var recommendationList = await command.Process(this.CurrentContext, customerId);
        return recommendationList != null ? (IActionResult)new ObjectResult((object)recommendationList) : (IActionResult)this.NotFound();

On the Sitecore side, I setup an OData Connected Service to my commerce engine to the proper models and container to make the call. I created an extension method to get the shops container the same way the EngineConnectUtility does and make my call to get the recommendations in the Pipeline Processor like so:

var recommendationsRequestQuery = container.GetRecommendations(request.CustomerId);
var recommendationsResult = Proxy.GetValue(recommendationsRequestQuery);

The problem is, every time I make the call to get the recommendations, I get the following error:

System.InvalidOperationException: 'The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to 'http://docs.oasis-open.org/odata/ns/data' namespace.'

I am not sure why I am getting this error and have been digging through it for a while. I made a test call to get a category from the very same container I used to get the recommendations and it works just fine. So, something tells me that there is something either wrong with the response object or the Context of the container.

1 Answer 1


Figured out the answer! After digging around the the commerce assemblies on the Engine side, I found that I needed to add the following in the ConfigureServiceApiBlock:


Postman was fine with not having this set in here and I was able to see the json result. However, the OData connect did not accept it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.