1

My action method:

    [Authorize]
    [HttpGet]
    [Produces("text/xml")]
    public async Task<GetJobsForThirdPartyResponse> GetJobs(GetJobsForThirdPartyQuery query)        
    {            
        var response = await this.Bus.Query(query);
        return response.Data;
    }

My partial Startup class:

services.AddMvc(options =>
        {
            options.OutputFormatters.Add(new XmlSerializerOutputFormatter());
        });

Postman request is like bellow: enter image description here
enter image description here

I've also tried [Produces("application/xml")] with Accept: application/xml header request. But no luck.

Towhid
  • 1,920
  • 3
  • 36
  • 57
  • Can you try with json. or default output to ensure this issue with xml – Eldho Nov 17 '19 at 06:13
  • Yes it produces json successfully. Problem is with XML. – Towhid Nov 17 '19 at 06:16
  • you are writing XML or JSON at the body? if you specify XML to be the format then set the body to be XML too; did you try that? – Mahmoud Shaaban Nov 17 '19 at 06:24
  • Yes I've done that by selecting `Body` tab then by selecting `XML` option in postman. Even I've removed the parameter from action method like `GetJobs()`. Still no hope. – Towhid Nov 17 '19 at 07:32
  • I was also facing similar problem but the answer in this thread https://stackoverflow.com/questions/26822277/return-html-from-asp-net-web-api helped me a lot. – N. Raj Feb 05 '21 at 00:05

0 Answers0