开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜