Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

ServiceAPI: Organization APIs cannot return xml output

Found in

EPiServer.ServiceApi 4.1.0

Fixed in

EPiServer.ServiceApi 4.2.0

(Or a related package)

Created

Oct 04, 2017

Updated

Dec 05, 2017

Area

Service API

State

Closed, Fixed and tested


Description

Steps to reproduce:

  1. Run GET organization to return xml output

    public string GetAllOrganizations()
            {
                var  result = GetXml($"/episerverapi/commerce/customers/organization/").Result.Content.ReadAsStringAsync().Result;
                WriteTextFile(Path.Combine(_customerOutputPath, "GetAllOrganizationXml.xml"), result);
                return "Get all organizations completed";
            }
    

    • Expected: output file is xml format
    • Actual: output file is json format
  2. Run POST Organization to return xml output
    • Expected: output file is xml format
    • Actual: output file shows exception

      <Error><Message>The request entity's media type 'application/xml' is not supported for this resource.</Message><ExceptionMessage>No MediaTypeFormatter is available to read an object of type 'Organization' from content with media type 'application/xml'.</ExceptionMessage><ExceptionType>System.Net.Http.UnsupportedMediaTypeException</ExceptionType><StackTrace>   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)
         at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)</StackTrace></Error>
      
      

  • Note: the issue does not happen with Contact API