Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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": "my first watchlist",
// "symbols": [
// "AAPL",
// "LMND",
// "PLTR",
// "AMZN",
// "CSCO",
// "A"
// ]
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "name" "my first watchlist" To iSuccess
Get ComUpdateString Of hoJson "symbols[0]" "AAPL" To iSuccess
Get ComUpdateString Of hoJson "symbols[1]" "LMND" To iSuccess
Get ComUpdateString Of hoJson "symbols[2]" "PLTR" To iSuccess
Get ComUpdateString Of hoJson "symbols[3]" "AMZN" To iSuccess
Get ComUpdateString Of hoJson "symbols[4]" "CSCO" To iSuccess
Get ComUpdateString Of hoJson "symbols[5]" "A" To iSuccess
Send ComSetRequestHeader To hoHttp "Apca-Api-Secret-Key" "{{APCA_API_SECRET_KEY}}"
Send ComSetRequestHeader To hoHttp "Apca-Api-Key-Id" "{{APCA_API_KEY_ID}}"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://domain.com/v2/watchlists" "application/json" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
Curl Command
curl -X POST
-H "Apca-Api-Key-Id: {{APCA_API_KEY_ID}}"
-H "Apca-Api-Secret-Key: {{APCA_API_SECRET_KEY}}"
-d '{
"name": "my first watchlist",
"symbols": ["AAPL","LMND","PLTR","AMZN","CSCO","A"]
}'
https://domain.com/v2/watchlists
Postman Collection Item JSON
{
"name": "Watchlist",
"request": {
"method": "POST",
"header": [
{
"key": "Apca-Api-Key-Id",
"value": "{{APCA_API_KEY_ID}}",
"type": "text"
},
{
"key": "Apca-Api-Secret-Key",
"value": "{{APCA_API_SECRET_KEY}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"my first watchlist\",\n \"symbols\": [\"AAPL\",\"LMND\",\"PLTR\",\"AMZN\",\"CSCO\",\"A\"]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HOST}}/v2/watchlists",
"host": [
"{{HOST}}"
],
"path": [
"v2",
"watchlists"
]
},
"description": "| Parameter | Type | Requirement |\n|-------------|---------------|:-----------:|\n| `name` | string | Required |\n| `symbols` | array[string] | Optional |"
},
"response": [
]
}