Pramod Mallar
Pramod Mallar

Reputation: 21

Azure API Management - Defining Custom Error

I'm using Azure API management for my project, with a backend service provided by Fiorano ESB. Fiorano to Azure has a peer-to-peer connectivity. The services is deployed in the peer server which is added as a cloud service in azure. So my concern is : for an API, in the URL if the resource is missing or wrong by default we'll get a json response as

{
    "stausCode" : 404,
    "message" : "Resource not found"
}

Is there any way that I can define this in OData standard format i.e. can i define it in a custom format as given below:

{
    "error":{  
    "code" : "404_RES",                                                                                                   
    "message":{                                                                                                                        
        "lang":"en-uk",                                                                                                             
        "value":"Resource $(wrong_resource given) is not found"                                                                              
     },                                                                                                                    
    "innererror":{ 
  "trace":[],                                                                                                               
    "context":{}    
     }                                                                                                         
     }
 }

The $(wrong resource) should be taken dynamically

Upvotes: 2

Views: 1672

Answers (1)

Andrey Ilnitsky
Andrey Ilnitsky

Reputation: 606

Take a look at set-body policy: https://msdn.microsoft.com/en-us/library/azure/dn894083.aspx#SetBody. Basically, it allows you to modify/replace message bodies of incoming and outgoing requests.

Upvotes: 1

Related Questions