Return Json Exception
The graph facebook API return this error if you dont provide a valid token:
{
"error": {
"type": "OAuthException",
"message": "An access token is required to request this resource."
}
}
In case you make a valid call the json result is returned.
In WCF with .net 4 how can I return the same Json "exception" with this method:
[WebGet(UriTemplate = "{id}")]
public SampleIte开发者_运维技巧m Get(string id)
{
if (id.Length != 4)
"how to return here the error since this method return a sample item class"????
else
return rep.GetSampleByID(id);
}
I think I find one way. Returning a stream and managing the returning content type. based on this answer
精彩评论