Azure Worker Role returns XML instead of JSON

Someone asked on Stack Overflow:

I’ve been following a blog post from Brady Gaster to create a Azure worker role to create a JSON endpoint.

All is going well, create a worker role and deployed to Azure with no problem except it returns XML instead of JSON.

It returns the following result:

<ArrayOfMessage xmlns="http://schemas.datacontract.org/2004/07/Backend.Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message><Id>5de2ed85-1eb1-4306-aace-645ea9202f26</Id></Message></ArrayOfMessage>

While I expected just a GUID something like:

{
  Id: '5de2ed85-1eb1-4306-aace-645ea9202f26'
}

Not sure whats wrong, followed the code examples from the blog post. Unfortunately his codesamples weren’t available for download so I can’t compare specific configuration…

Any ideas?

Are you sending the JSON accept header with your request?

Different clients will send different accept headers by default, and you may need to override them to get the type of response that you’re looking to get.


Originally posted on Stack Overflow — 1 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.