开发者

Return Json Exception

开发者 https://www.devze.com 2023-02-03 02:03 出处:网络
The graph facebook API return this error if you dont provide a valid token: { \"error\": { \"type\": \"OAuthException\",

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

精彩评论

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