POST $batch
The batching capability allows an API consumer to send as many requests with any HTTP Verb as the API maintainers will allow – for instance you can combine a POST call with DELETE and GET or PUT all in one request, including requests that still support OData querying.
Body
{ "requests": [
{
"method": "GET",
"url": "https://localhost:7139/odata/Accounts?$select=Name,Number,Master",
"id": "response1"
},
{
"method": "GET",
"url": "https://localhost:7139/odata/Positions?$filter=marketValue gt 30000 and OriginalCost lt 1500&$orderby=ProcessDate desc",
"id": "response2"
}
]
}
Example Request
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySW5mbyI6IntcIklkXCI6OTgxLFwiSWRlbnRpdHlJZFwiOlwiNjMyMzhhZTQtMzAyMC00NWI5LWEwODktOTE2ZTY4MDMyZTY3XCIsXCJVc2VyTmFtZVwiOlwiMF9URVNUX0NMSUVOVFwiLFwiRW1haWxcIjpcInRlc3RjbGllbnRAd2VhbHRodGVjaHMuY29tXCIsXCJGaXJzdE5hbWVcIjpcIlRlc3RcIixcIkxhc3ROYW1lXCI6XCJDbGllbnRcIixcIklzQ2xpZW50VXNlclwiOmZhbHNlfSIsIm5iZiI6MTY5NDcwMjU3OSwiZXhwIjoxOTI0OTIzNjAwLCJpc3MiOiJXZWFsdGhUZWNocyIsImF1ZCI6IkFQSVVzZXJzIn0.bNcP0ouNwtFoxrI7pYXw0WKiw0TN6w_R2-Ban5moo1A");
var raw = "{ \"requests\": [\r\n {\r\n \"method\": \"GET\",\r\n \"url\": \"https://localhost:7139/odata/Accounts?$select=Name,Number,Master&$top=5\",\r\n \"id\": \"response1\"\r\n },\r\n {\r\n \"method\": \"GET\",\r\n \"url\": \"https://localhost:7139/odata/Positions?$filter=marketValue gt 30000 and OriginalCost lt 1500&$orderby=ProcessDate desc&$top=5\",\r\n \"id\": \"response2\"\r\n }\r\n ]\r\n}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.wealthtechs.com/v2/odata/$batch", requestOptions)
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
{
"responses": [
{
"id": "response1",
"status": 200,
"headers": {
"content-type": "application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8",
"odata-version": "4.0"
},
"body": {
"@odata.context": "https://localhost:7139/v2/odata/$metadata#Accounts(Name,Number,Master)",
"value": [
{
"Number": "Y56489736S",
"Master": "123456789",
"Name": "Test Account Name"
},
{
"Number": "X52301589R",
"Master": null,
"Name": "Test Account Name"
},
{
"Number": "Z33591184T",
"Master": "123456789",
"Name": "Test Account Name"
},
{
"Number": "Y41213443S",
"Master": "123456789",
"Name": "Test Account Name"
},
{
"Number": "Y73106158S",
"Master": "123456789",
"Name": "Test Account Name"
}
]
}
},
{
"id": "response2",
"status": 200,
"headers": {
"content-type": "application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8",
"odata-version": "4.0"
},
"body": {
"@odata.context": "https://localhost:7139/v2/odata/$metadata#Positions",
"value": [
{
"CustodianId": 73,
"CustomerId": 0,
"ProcessDate": "2023-09-13T00:00:00-04:00",
"AccountId": 7,
"SecurityId": 5682,
"ShortPosition": false,
"Quantity": 165601.60487874,
"MarketValue": 165601.60487874,
"OriginalCost": 0,
"OriginalCostDate": "1950-01-01T00:00:00-05:00",
"OriginalFace": null
},
{
"CustodianId": 73,
"CustomerId": 0,
"ProcessDate": "2023-09-13T00:00:00-04:00",
"AccountId": 8,
"SecurityId": 5696,
"ShortPosition": false,
"Quantity": 218804.63342237,
"MarketValue": 218804.63342237,
"OriginalCost": 0,
"OriginalCostDate": "1950-01-01T00:00:00-05:00",
"OriginalFace": null
},
{
"CustodianId": 73,
"CustomerId": 0,
"ProcessDate": "2023-09-12T00:00:00-04:00",
"AccountId": 7,
"SecurityId": 5682,
"ShortPosition": false,
"Quantity": 165605.47999234,
"MarketValue": 165605.47999234,
"OriginalCost": 0,
"OriginalCostDate": "1950-01-01T00:00:00-05:00",
"OriginalFace": null
},
{
"CustodianId": 73,
"CustomerId": 0,
"ProcessDate": "2023-09-12T00:00:00-04:00",
"AccountId": 8,
"SecurityId": 5682,
"ShortPosition": true,
"Quantity": 42388.74182401,
"MarketValue": 42388.74182401,
"OriginalCost": 0,
"OriginalCostDate": "1950-01-01T00:00:00-05:00",
"OriginalFace": null
},
{
"CustodianId": 73,
"CustomerId": 0,
"ProcessDate": "2023-09-12T00:00:00-04:00",
"AccountId": 8,
"SecurityId": 5696,
"ShortPosition": false,
"Quantity": 274444.08942237,
"MarketValue": 274444.08942237,
"OriginalCost": 0,
"OriginalCostDate": "1950-01-01T00:00:00-05:00",
"OriginalFace": null
}
]
}
}
]
}
Learn how to get access to our API V2.0 by clicking here.
You can copy and use our API v2.0 Example Token to get familiar with our API OData Resources.