Skip to content

C# SDK Configuration

Pawel Sawicz edited this page Mar 26, 2015 · 9 revisions

C# SDK Configuration

First of all you have to download JustGiving SDK package from NuGet.org either from website JustGiving SDK or by command

PM> Install-Package justgiving-sdk

Then if you have downloaded a JustGiving SDK you have to create an instance of JustGivingClient

var client = new JustGiving.Api.Sdk.JustGivingClient("APIKEY");

Code above is required to do any request against our API!

If you would like to change an environment simply you have to create an instance of ClientConfiguration

var clientConfig = new Api.Sdk.ClientConfiguration("https://api-sandbox.justgiving.com/", "api-key", 1);

or for live server

var clientConfig = new Api.Sdk.ClientConfiguration("https://api.justgiving.com/", "api-key", 1);

and then pass into JustGivingClient argument

var client = new JustGiving.Api.Sdk.JustGivingClient(clientConfig);

To add authentication for your request, simply you have to set up username and password for client

clientConfig.Username = "username";
clientConfig.Password = "password";

Data API

If you are going to use C# SDK against Data API you can set up connection configuration by two ways either by new attribute into your web.config or app.config or by setting up values for configuration object

Attribute in config file way

<justGivingDataSdk CharityId="yourCharityId" RootDomain="environmentAPIUrl " ApiVersion="1" ApiKey="yourAppKey" Username="justgivingUserName" Password="password" />

RootDomain is basically an endpoint of chosen environment (live or sandbox) http://dataapi.justgiving.com/ or http://dataapi-sandbox.justgiving.com/

Properties set up way

var dataConfig = new DataClientConfiguration("https://dataapi-sandbox.justgiving.com/", "apiKey", 1);
dataConfig.CharityId = 2050;
dataConfig.Username = "userName";
dataConfig.Password = "password";
var client = new JustGivingDataClient(dataConfig);

This is required to make any request against Data API.

Clone this wiki locally