Chilkat Online Tools

VB.NET / CardPointe API Integration / Profile (Create/Update)

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

http.BasicAuth = True
http.Login = "username"
http.Password = "password"

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

' The following JSON is sent in the request body.

' {
'   "name": "Carson Wentz",
'   "address": "100 S. Broad Street",
'   "city": "Philadelphia",
'   "region": "PA",
'   "country": "US",
'   "postal": "19103",
'   "merchid": "{{merchid}}",
'   "account": "{{account}}",
'   "expiry": "{{expiry}}",
'   "currency": "{{currency}}"
' }

Dim json As New Chilkat.JsonObject
json.UpdateString("name","Carson Wentz")
json.UpdateString("address","100 S. Broad Street")
json.UpdateString("city","Philadelphia")
json.UpdateString("region","PA")
json.UpdateString("country","US")
json.UpdateString("postal","19103")
json.UpdateString("merchid","{{merchid}}")
json.UpdateString("account","{{account}}")
json.UpdateString("expiry","{{expiry}}")
json.UpdateString("currency","{{currency}}")

http.SetRequestHeader("Authorization","{{Authorization}}")
http.SetRequestHeader("Content-Type","application/json")

Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)

Dim resp As Chilkat.HttpResponse = http.PTextSb("PUT","https://domain.com/profile",sbRequestBody,"utf-8","application/json",False,False)
If (http.LastMethodSuccess = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


Debug.WriteLine(resp.StatusCode)
Debug.WriteLine(resp.BodyStr)

Curl Command

curl -X PUT
	-u 'username:password'
	-H "Authorization: {{Authorization}}"
	-H "Content-Type: application/json"
	-d '{
    "name": "Carson Wentz",
    "address": "100 S. Broad Street",
    "city": "Philadelphia",
    "region": "PA",
    "country": "US",
    "postal": "19103",
    "merchid": "{{merchid}}",
    "account": "{{account}}",
    "expiry": "{{expiry}}",
    "currency": "{{currency}}"
}'
https://domain.com/profile

Postman Collection Item JSON

{
  "name": "Profile (Create/Update)",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var jsonData = JSON.parse(responseBody);",
          "postman.setEnvironmentVariable(\"profileid\", jsonData.profileid);",
          "var jsonData = JSON.parse(responseBody);",
          "postman.setEnvironmentVariable(\"acctid\", jsonData.acctid);"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "auth": {
      "type": "basic",
      "basic": [
        {
          "key": "password",
          "value": "testing123",
          "type": "string"
        },
        {
          "key": "username",
          "value": "testing",
          "type": "string"
        },
        {
          "key": "showPassword",
          "value": false,
          "type": "boolean"
        }
      ]
    },
    "method": "PUT",
    "header": [
      {
        "key": "Authorization",
        "value": "{{Authorization}}"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"name\": \"Carson Wentz\",\n    \"address\": \"100 S. Broad Street\",\n    \"city\": \"Philadelphia\",\n    \"region\": \"PA\",\n    \"country\": \"US\",\n    \"postal\": \"19103\",\n    \"merchid\": \"{{merchid}}\",\n    \"account\": \"{{account}}\",\n    \"expiry\": \"{{expiry}}\",\n    \"currency\": \"{{currency}}\"\n}"
    },
    "url": {
      "raw": "{{url}}/profile",
      "host": [
        "{{url}}"
      ],
      "path": [
        "profile"
      ]
    },
    "description": "[Profile Documentation](https://developer.cardconnect.com/cardconnect-api#profile)"
  },
  "response": [
  ]
}