I am using the Azure Data Tables JavaScript API, and would like to specify request header item as follows:-
contentType: application/json;odata=nometadata
I've looked through the documentation (https://docs.microsoft.com/en-us/javascript/api/@azure/data-tables/?view=azure-node-latest) and there are some methods which facilitate changes to the request header, e.g. TableInsertEntityHeaders interface includes a property 'contentType'.
the TableClient.listEntities method includes a parameter (options?: ListTableEntitiesOptions) which does not include header access. So, as far as I can see, there is no obvious functionality supplied by the API to change the Request Header.
thank you
You can specify this in format parameter in the query options. Please see the sample code below:
const { TableClient, AzureNamedKeyCredential } = require("@azure/data-tables");
const account = "account-name";
const accountKey = "account-key";
const tableName = "table-name";
const credential = new AzureNamedKeyCredential(account, accountKey);
const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
async function main() {
let entitiesIter = client.listEntities({
queryOptions: {
format: "application/json;odata=nometadata"
}
});
let i = 1;
for await (const entity of entitiesIter) {
console.log(`Entity ${i}:`);
console.log(entity);
console.log('==================');
i++;
}
}
main();