on 12-16-2020 9:16 AM
{
"d":
{"results":
[{"__metadata": {"id": "https://sapes5.sapdevcenter/******/purchaseorders"uri": "https://sapes5.sapdevcenter/******/purchaseorders"
type": "SEPMRA_PO_APV.PurchaseOrder"
},
"ChangedAt": "/Date(1606604400000)/","ProductId": "","CurrencyCode": "USD","DeliveryAddress": "Zeppelinstrasse 2, 8
Here i want to remove or Hide that metadata in the json . When ever call an api that odata response has meta data . Its possible to remove that metadata in sap api management by using javascript policy and some other policies in api portal . Do you have any idea how to implement this
Hi,
make sure it's all the time a json response, then you can remove the metadata object.
Something like this should work (I didn't try, have something similar in place)
var response = context.getVariable("response.content");
var j = JSON.parse(response).d.results;
// delete you metadata content
j.forEach(function(item, index){
try{
j[index].__metadata = "Metadata is now hidden";
}catch(e){ }
});
response = JSON.stringify(j);
context.setVariable("response.content", response);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi kvrsaicharan1152,
As metadata is a object named "__metadata", you can use the regex expression in Javascript policy to remove the object __metadata from the response, this will remove every metadata object present in your response.
Hope it helps!
Br/ Sai Sreenivas Addepalli.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In OData V4 there is nearly no metadata in an OData response anymore.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.