The Http method used is GET, and I call the same webservice method (with the same parameters).
But if I add an Accept header for the request with the / json application, the output is different. The reason is the Bitmap field in my object named User, which contains an avatar image.
If I do not use the Accept / json header, this is simplified output (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>
</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>
Ok, that’s just great! Image (Base64) is. If I change my request for JSON, it will not receive any image, just the name of the class 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"
},
]
Mthod web service -
public IQueryable<User> Get()
{
// return stuff (no big deal here)
}
The code is the same, so why doesn't JSON return a base64 string, how should it be?
source
share