Xbase++
Xbase++
Yousign: Making your first API call
See more Yousign Examples
Demonstrates making the simplest of calls to test your API key. This example tests using the sandbox URLs.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cName
LOCAL cStrVal
LOCAL cId
LOCAL cFirstname
LOCAL cLastname
LOCAL cEmail
LOCAL cTitle
LOCAL cPhone
LOCAL cStatus
LOCAL cOrganization
LOCAL cPermission
LOCAL cGroupId
LOCAL cGroupName
LOCAL cCreatedAt
LOCAL cUpdatedAt
LOCAL nDeleted
LOCAL cDeletedAt
LOCAL cInweboUserRequest
LOCAL cSamlNameId
LOCAL cDefaultSignImage
LOCAL nNotificationsProcedure
LOCAL nFastSign
LOCAL cFullName
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Implements the following CURL command:
// curl --location --request GET 'https://staging-api.yousign.com/users' \
// --header 'Authorization: Bearer YOUR_API_KEY' \
// --header 'Content-Type: application/json'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer YOUR_API_KEY" header.
oHttp:AuthToken := "YOUR_API_KEY"
oHttp:SetRequestHeader("Content-Type", "application/json")
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://staging-api.yousign.com/users", oSbResponseBody)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastHeader
? "Failed."
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
RETURN
ENDIF
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "/users/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "firstname": "John",
// "lastname": "Doe",
// "email": "john.doe@yousign.fr",
// "title": "Developer",
// "phone": "+33612345678",
// "status": "activated",
// "organization": "/organizations/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "workspaces": [
// {
// "id": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "Acme"
// }
// ],
// "permission": "ROLE_ADMIN",
// "group": {
// "id": "/user_groups/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "Administrateur",
// "permissions": [
// "procedure_write",
// "procedure_template_write",
// "procedure_create_from_template",
// "contact",
// "sign",
// "organization",
// "user",
// "api_key",
// "procedure_custom_field",
// "signature_ui",
// "certificate",
// "archive"
// ]
// },
// "createdAt": "2018-12-01T09:42:25+01:00",
// "updatedAt": "2018-12-01T09:42:25+01:00",
// "deleted": false,
// "deletedAt": null,
// "config": [
// ],
// "inweboUserRequest": null,
// "samlNameId": null,
// "defaultSignImage": null,
// "notifications": {
// "procedure": true
// },
// "fastSign": false,
// "fullName": "John Doe"
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
cId := oJResp:StringOf("id")
cFirstname := oJResp:StringOf("firstname")
cLastname := oJResp:StringOf("lastname")
cEmail := oJResp:StringOf("email")
cTitle := oJResp:StringOf("title")
cPhone := oJResp:StringOf("phone")
cStatus := oJResp:StringOf("status")
cOrganization := oJResp:StringOf("organization")
cPermission := oJResp:StringOf("permission")
cGroupId := oJResp:StringOf("group.id")
cGroupName := oJResp:StringOf("group.name")
cCreatedAt := oJResp:StringOf("createdAt")
cUpdatedAt := oJResp:StringOf("updatedAt")
nDeleted := oJResp:BoolOf("deleted")
cDeletedAt := oJResp:StringOf("deletedAt")
cInweboUserRequest := oJResp:StringOf("inweboUserRequest")
cSamlNameId := oJResp:StringOf("samlNameId")
cDefaultSignImage := oJResp:StringOf("defaultSignImage")
nNotificationsProcedure := oJResp:BoolOf("notifications.procedure")
nFastSign := oJResp:BoolOf("fastSign")
cFullName := oJResp:StringOf("fullName")
i := 0
nCount_i := oJResp:SizeOfArray("workspaces")
DO WHILE i < nCount_i
oJResp:I := i
cId := oJResp:StringOf("workspaces[i].id")
cName := oJResp:StringOf("workspaces[i].name")
i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("group.permissions")
DO WHILE i < nCount_i
oJResp:I := i
cStrVal := oJResp:StringOf("group.permissions[i]")
i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("config")
DO WHILE i < nCount_i
oJResp:I := i
i := i + 1
ENDDO
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()