Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

C# Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(C#) SugarCRM Authenticate

Demonstrates how to authenticate to the SugarCRM REST v10 API. This is how an OAuth2 access token is obtained.

Chilkat .NET Downloads

Chilkat .NET Framework

Chilkat for .NET Core

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

success = rest.Connect("your.site.domain",443,true,true);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.AddHeader("Cache-Control","no-cache");

// The following code creates the JSON request body.
// The JSON created by this code is shown below.
Chilkat.JsonObject jsonReq = new Chilkat.JsonObject();
jsonReq.UpdateString("grant_type","password");
jsonReq.UpdateString("client_id","sugar");
jsonReq.UpdateString("client_secret","CLIENT_SECRET");
jsonReq.UpdateString("username","admin");
jsonReq.UpdateString("password","password");
jsonReq.UpdateString("platform","custom_api");

// The JSON request body created by the above code:

// {
//   "grant_type": "password",
//   "client_id": "sugar",
//   "client_secret": "CLIENT_SECRET",
//   "username": "admin",
//   "password": "password",
//   "platform": "custom_api"
// }

Chilkat.StringBuilder sbReq = new Chilkat.StringBuilder();
jsonReq.EmitSb(sbReq);

rest.AddHeader("Content-Type","application/json");

Chilkat.StringBuilder sbJson = new Chilkat.StringBuilder();
success = rest.FullRequestSb("POST","/rest/v10/oauth2/token",sbReq,sbJson);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

if (rest.ResponseStatusCode != 200) {
    Debug.WriteLine("Received error response code: " + Convert.ToString(rest.ResponseStatusCode));
    Debug.WriteLine("Response body:");
    Debug.WriteLine(sbJson.GetAsString());
    return;
}

Chilkat.JsonObject json = new Chilkat.JsonObject();
json.LoadSb(sbJson);

// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
string access_token;
int expires_in;
string token_type;
bool scope;
string refresh_token;
int refresh_expires_in;
string download_token;

access_token = json.StringOf("access_token");
expires_in = json.IntOf("expires_in");
token_type = json.StringOf("token_type");
scope = json.IsNullOf("scope");
refresh_token = json.StringOf("refresh_token");
refresh_expires_in = json.IntOf("refresh_expires_in");
download_token = json.StringOf("download_token");

// A sample JSON response body that is parsed by the above code:

// {
//   "access_token": "c6d495c9-bb25-81d2-5f81-533ef6479f9b",
//   "expires_in": 3600,
//   "token_type": "bearer",
//   "scope": null,
//   "refresh_token": "cbc40e67-12bc-4b56-a1d9-533ef62f2601",
//   "refresh_expires_in": 1209600,
//   "download_token": "cc5d1a9f-6627-3349-96e5-533ef6b1a493"
// }

Debug.WriteLine("Example Completed.");

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.