none
Atom feed generate for ASP.NETWebAPI RRS feed

  • Question

  • Hi All,

    i have a requirement to generate the Atom using the webapi, i try but always it is showing the atom as json text and my standard atom reader is not reading that message, can any one suggest an approach to achieve this functionality, 

    Advance thanks,

    Vijay

    Tuesday, November 20, 2018 4:45 PM

All replies

  • Hi aluvala vijay,

    You could force the response to always be atom+xml  with "application/atom+xml" like below, you could chose one of them.

    public HttpResponseMessage GetFeed()
    {
        return Request.CreateResponse(HttpStatusCode.OK, feedInstance, "application/atom+xml");
    }
    
    
     public HttpResponseMessage GetFeed()
     {
        return Request.CreateResponse(HttpStatusCode.OK, feedInstance, feedFormatter, "application/atom+xml");
     }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 21, 2018 2:02 AM
    Moderator
  • Hi Zhanglong,

    Thanks for your quick reply, i am currently using the .net Core, seems it will not support the Resquest.CreateResponse, is there any other way we can achieve this in the .netcore. please point me to any sample code that will be highly appreciated 

    Advance Thanks,

    Vijay

    Wednesday, November 21, 2018 4:07 AM
  • Hi aluvala vijay,

    Please add the following attribute ([Produces("application/atom+xml")]) on your web api method

     [HttpGet]
     [Produces("application/atom+xml")]
     public ActionResult<IEnumerable<string>> Get()
     {
         return new string[] { "value1", "value2" };
     }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 21, 2018 5:59 AM
    Moderator