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

PowerBuilder 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
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
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
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
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

 

 

 

(PowerBuilder) Google People API - Update an Existing Contact

To update an existing contact, you must include the person.metadata.sources.etag field in the person for the contact to be updated to make sure the contact has not changed since your last read.

For more information, see https://developers.google.com/people/v1/contacts#update-an-existing-contact

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_JsonToken
integer li_Success
oleobject loo_Http
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_type
string ls_Id
string ls_UpdateTime
integer li_MetadataPrimary
string ls_MetadataSourceType
string ls_MetadataSourceId
string ls_DisplayName
string ls_FamilyName
string ls_GivenName
string ls_DisplayNameLastFirst
string ls_UnstructuredName
string ls_Url
integer li_Default
string ls_Value
string ls_ContactGroupMembershipContactGroupId
string ls_ContactGroupMembershipContactGroupResourceName
string ls_ResourceName
string ls_Etag
string ls_MetadataObjectType
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// It is assumed we previously obtained an OAuth2 access token.
// This example loads the JSON access token file 

// originally obtained by this example: Get Google People API OAuth2 Access Token
// or refreshed by this example: Refresh Google People API OAuth2 Access Token

loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
if li_rc < 0 then
    destroy loo_JsonToken
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/googlePeople.json")
if li_Success <> 1 then
    Write-Debug "Failed to load googleContacts.json"
    destroy loo_JsonToken
    return
end if

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")

loo_Http.AuthToken = loo_JsonToken.StringOf("access_token")

// Implements the following CURL command:

// curl -X PATCH https://people.googleapis.com/v1/resource_name:updateContact?updatePersonFields=emailAddresses \
//   -H "Content-Type: application/json" \
//   -d '{
//     "resourceName": "resource_name",
//     "etag": "#eyZ0Gu5HVas=",
//     "emailAddresses": [{ "value": "john.doe@gmail.com" }],
// }'

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "resourceName": "resource_name",
//   "etag": "#eyZ0Gu5HVas=",
//   "emailAddresses": [
//     {
//       "value": "john.doe@gmail.com"
//     }
//   ]
// }

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("resourceName","people/c172365763025317520")
loo_Json.UpdateString("etag","%EigBAj0DBAUGBwgJPgoLPwwNDg8QQBESExQVFhc1GTQ3HyEiIyQlJicuGgQBAgUHIgxleVowR3U1SFZhcz0=")
loo_Json.UpdateString("emailAddresses[0].value","john.doe@gmail.com")

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Json.EmitSb(loo_SbRequestBody)

// Notice that the resource name is part of the URL...
loo_Resp = loo_Http.PTextSb("PATCH","https://people.googleapis.com/v1/people/c172365763025317520:updateContact?updatePersonFields=emailAddresses",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_JsonToken
    destroy loo_Http
    destroy loo_Json
    destroy loo_SbRequestBody
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_JsonToken
    destroy loo_Http
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "resourceName": "people/c172365763025317520",
//   "etag": "%EigBAj0DBAUGBwgJPgoLPwwNDg8QQBESExQVFhc1GTQ3HyEiIyQlJicuGgQBAgUHIgxtQnhyR2MzMGU4Yz0=",
//   "metadata": {
//     "sources": [
//       {
//         "type": "CONTACT",
//         "id": "2645dbf8c902e90",
//         "etag": "#mBxrGc30e8c=",
//         "updateTime": "2020-08-03T23:01:23.539Z"
//       }
//     ],
//     "objectType": "PERSON"
//   },
//   "names": [
//     {
//       "metadata": {
//         "primary": true,
//         "source": {
//           "type": "CONTACT",
//           "id": "2645dbf8c902e90"
//         }
//       },
//       "displayName": "John Doe",
//       "familyName": "Doe",
//       "givenName": "John",
//       "displayNameLastFirst": "Doe, John",
//       "unstructuredName": "John Doe"
//     }
//   ],
//   "photos": [
//     {
//       "metadata": {
//         "primary": true,
//         "source": {
//           "type": "CONTACT",
//           "id": "2645dbf8c902e90"
//         }
//       },
//       "url": "https://lh3.googleusercontent.com/-XdUIqeMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/V8BNOaftJmYG2hHugNzYued7G9QFdeZOACLcDEAEiGQoBShD___________8BGNvwiP7______wE/s100/photo.jpg",
//       "default": true
//     }
//   ],
//   "emailAddresses": [
//     {
//       "metadata": {
//         "primary": true,
//         "source": {
//           "type": "CONTACT",
//           "id": "2645def8c902e90"
//         }
//       },
//       "value": "john.doe@gmail.com"
//     }
//   ],
//   "memberships": [
//     {
//       "metadata": {
//         "source": {
//           "type": "CONTACT",
//           "id": "2645dbf8c902e90"
//         }
//       },
//       "contactGroupMembership": {
//         "contactGroupId": "myContacts",
//         "contactGroupResourceName": "contactGroups/myContacts"
//       }
//     }
//   ]
// }

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

ls_ResourceName = loo_JResp.StringOf("resourceName")
ls_Etag = loo_JResp.StringOf("etag")
ls_MetadataObjectType = loo_JResp.StringOf("metadata.objectType")
i = 0
li_Count_i = loo_JResp.SizeOfArray("metadata.sources")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("metadata.sources[i].type")
    ls_Id = loo_JResp.StringOf("metadata.sources[i].id")
    ls_Etag = loo_JResp.StringOf("metadata.sources[i].etag")
    ls_UpdateTime = loo_JResp.StringOf("metadata.sources[i].updateTime")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("names")
do while i < li_Count_i
    loo_JResp.I = i
    li_MetadataPrimary = loo_JResp.BoolOf("names[i].metadata.primary")
    ls_MetadataSourceType = loo_JResp.StringOf("names[i].metadata.source.type")
    ls_MetadataSourceId = loo_JResp.StringOf("names[i].metadata.source.id")
    ls_DisplayName = loo_JResp.StringOf("names[i].displayName")
    ls_FamilyName = loo_JResp.StringOf("names[i].familyName")
    ls_GivenName = loo_JResp.StringOf("names[i].givenName")
    ls_DisplayNameLastFirst = loo_JResp.StringOf("names[i].displayNameLastFirst")
    ls_UnstructuredName = loo_JResp.StringOf("names[i].unstructuredName")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("photos")
do while i < li_Count_i
    loo_JResp.I = i
    li_MetadataPrimary = loo_JResp.BoolOf("photos[i].metadata.primary")
    ls_MetadataSourceType = loo_JResp.StringOf("photos[i].metadata.source.type")
    ls_MetadataSourceId = loo_JResp.StringOf("photos[i].metadata.source.id")
    ls_Url = loo_JResp.StringOf("photos[i].url")
    li_Default = loo_JResp.BoolOf("photos[i].default")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("emailAddresses")
do while i < li_Count_i
    loo_JResp.I = i
    li_MetadataPrimary = loo_JResp.BoolOf("emailAddresses[i].metadata.primary")
    ls_MetadataSourceType = loo_JResp.StringOf("emailAddresses[i].metadata.source.type")
    ls_MetadataSourceId = loo_JResp.StringOf("emailAddresses[i].metadata.source.id")
    ls_Value = loo_JResp.StringOf("emailAddresses[i].value")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("memberships")
do while i < li_Count_i
    loo_JResp.I = i
    ls_MetadataSourceType = loo_JResp.StringOf("memberships[i].metadata.source.type")
    ls_MetadataSourceId = loo_JResp.StringOf("memberships[i].metadata.source.id")
    ls_ContactGroupMembershipContactGroupId = loo_JResp.StringOf("memberships[i].contactGroupMembership.contactGroupId")
    ls_ContactGroupMembershipContactGroupResourceName = loo_JResp.StringOf("memberships[i].contactGroupMembership.contactGroupResourceName")
    i = i + 1
loop


destroy loo_JsonToken
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp

 

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