The Http method used is GET and I'm calling the same webservice method (with same parameters).
But if I add to request an Accept header with application/json, the output differs. The cause is a Bitmap field in my object named User, which holds an avatar image.
If i leave out the Accept application/json header, this is the simplified output (XML):
<!-- language: lang-xml -->
<ArrayOfUser xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/XTraN4ForcesFSDomain.Domain">
<User>
<Id>02ddf1e4-ad76-4778-8887-a186014939f8</Id>
<Avatar xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Drawing" i:nil="true" />
<IsActive>false</IsActive>
<LastAccess>0001-01-01T00:00:00</LastAccess>
<Username>quisquam</Username>
<!-- Other properties -->
</User>
<User>
<Id>17db833c-5008-44f0-a713-a186014c22a5</Id>
<Avatar xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Drawing">
<Data xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:base64Binary" xmlns="">iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAAK/INwWK6[...]BIJS/Wd6Pgu/mOoS/HADwfwFUI4VkJHOgAgAAAABJRU5ErkJggg==</Data>
</Avatar>
<IsActive>false</IsActive>
<LastAccess>0001-01-01T00:00:00</LastAccess>
<Username>labore</Username>
</User>
</ArrayOfUser>
Well, this is just fine! The image (Base64) is there. If I change my request to get JSON, it returns no image, just the name of the class that it represents:
<!-- language: lang-json -->
[
{
"Username": "quisquam",
"LastAccess": "0001-01-01T00:00:00",
"IsActive": false,
"Avatar": null,
"Id": "02ddf1e4-ad76-4778-8887-a186014939f8"
},
{
"Username": "reiciendis",
"LastAccess": "0001-01-01T00:00:00",
"IsActive": false,
"Avatar": "System.Drawing.Bitmap",
"Id": "17db833c-5008-44f0-a713-a186014c22a5"
},
]
The webservice mthod is
<!-- language: lang-c# -->
public IQueryable<User> Get()
{
// return stuff (no big deal here)
}
The code is the same, so why won't JSON return a base64 string like it should?