HeaderParameterCollection Class
A JSON endpoint’s HTTP header parameters collection.
Namespace: DevExpress.DataAccess.Json
Assembly: DevExpress.DataAccess.v24.2.dll
Declaration
Related API Members
The following members return HeaderParameterCollection objects:
Remarks
Use header parameters to add custom HTTP headers to JSON endpoint requests.
Add header parameters to a HeaderParameterCollection instance and assign the collection to the UriJsonSource.HeaderParameters property.
The parameters are added to endpoint requests in the same order in which they are stored in the collection. Change the order of elements in the collection to reposition parameters in endpoint requests.
Example
The code sample below specifies a JSON endpoint and uses the X-Date and X-Id header parameters to add custom HTTP headers to JSON endpoint requests. The X-Id header parameter is bound to the ID report parameter.
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
Uri = new Uri(@"https://localhost:44367/api/values")
};
// Create the "X-Date" and "X-Id" header parameters that are added to the JSON URI requests.
jsonSource.HeaderParameters.AddRange(new[] {
new HeaderParameter("X-Date", typeof(String), String.Format("{0:yyyy-MM-dd}", DateTime.Today)),
// "ID" is a report parameter whose value is used for the "X-Id" header parameter.
new HeaderParameter("X-Id", typeof(Expression), new Expression("?ID"))
});
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
JsonSource = jsonSource
};