Skip to main content
A newer version of this page is available. .

JsonDataSource.ConnectionName Property

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

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v19.1.dll

Declaration

[DefaultValue("")]
[LocalizableCategory(DataAccessStringId.PropertyGridConnectionCategoryName)]
public string ConnectionName { get; set; }

Property Value

Type Default
String String.Empty

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=http://northwind.servicestack.net/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 CreateReportDataSourceFromConnectionString() {
    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.

See Also