Skip to main content

JsonDataSource.ConnectionName Property

Specifies the connection name that the JsonDataSource uses to get authentication or query parameters.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v24.1.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

[LocalizableCategory(DataAccessStringId.PropertyGridConnectionCategoryName)]
[TypeConverter(typeof(ConnectionNameTypeConverter))]
public string ConnectionName { get; set; }

Property Value

Type
String

Remarks

If the JsonDataSource object retrieves JSON data from a web service endpoint that requests authentication, you should specify authentication parameters. To do this, you can use the JsonDataSource‘s ConnectionName property. Set this property to the name of the connection string defined in your application’s configuration file. The JsonDataSource object obtains authentication parameters from the specified connection string.

The following connection string illustrates how to specify basic authentication parameters, token-based authentication parameters and query parameters.

<configuration>
    <connectionStrings>
        <add name="JsonConnection" connectionString="Uri=https://northwind.netcore.io/customers.json;
            Username=user;Password=pwd;
            header:MyAuthHeader1=secretToken1;header:MyAuthHeader2=secretToken2;
            query:id=123456;query:name=MyName" 
        providerName="JsonSourceProvider" />
    </connectionStrings>
    <!--...-->
</configuration>

The following code demonstrates how to specify a JsonDataSource‘s ConnectionName property.

public static JsonDataSource CreateDataSourceFromConnectionString() {
    JsonDataSource jsonDataSource = new DevExpress.DataAccess.Json.JsonDataSource() {
        // The application's configuration file should include the "JsonConnection" connection string
        ConnectionName = "JsonConnection"
    };
    return jsonDataSource;
} 

Note

You can also use the JsonSource object associated with the JsonDataSource to specify authentication parameters.

Refer to the Provide Authentication to Access JSON Data (Runtime Sample) topic for information on how to provide a report‘s JSON data source with authentication parameters at runtime.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ConnectionName property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also