Sample Code
The following takes GetDataSourceList interface as an example,to introduce how to initiate a signed request through the SDK in two ways.
First method (recommended)
Instantiate
RequestHelperobject inPwC.Api.Sdk.RequestHelper requestHelper = new RequestHelper(appKey, securityKey, domain);Use
PostAsyncto initiate the request and obtain the results.// var response = await requestHelper.PostAsync("/tenant/appCode/customapi/GetDataSourceList", JsonConvert.DeserializeObject<Dictionary<string, object>>("{\"State\":-1}"));
Second method
Instantiate
RequestHelperobject inPwC.Api.Sdk.// RequestHelper requestHelper = new RequestHelper(appKey, securityKey, domain);Instantiate
ISigner// ISigner signer = new HmacSHA256();Get timestamp
// string timestamp = Common.GetDateTotalMilliseconds().ToString();Get random number
// string nonce = Common.GetNonce();Get the original signature string
// string sourceText = signer.GetStringToSign(requestData, appKey, securityKey, nonce, timestamp);Get signature
// string sign = signer.GetSign(sourceText);Use
PostAsyncto initiate a request and get the result// var response = await requestHelper.PostAsync("/tenant/appCode/customapi/GetDataSourceList", JsonConvert.DeserializeObject<Dictionary<string, object>>("{\"State\":-1}"), sign, nonce, timestamp);