DataFlex / New FreshBooks / Invite Team Member to Project(s)
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.
// {
// "capacity": "manager",
// "to_email": "yourteammemberemail@freshbooks.com",
// "invitable_id": 123,
// "invitable_type": "business",
// "groups": [
// {
// "group_id": 6360979,
// "capacity": "manager"
// },
// {
// "group_id": 6360987,
// "capacity": "manager"
// },
// {
// "group_id": 6360952,
// "capacity": "manager"
// }
// ]
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "capacity" "manager" To iSuccess
Get ComUpdateString Of hoJson "to_email" "yourteammemberemail@freshbooks.com" To iSuccess
Get ComUpdateInt Of hoJson "invitable_id" 123 To iSuccess
Get ComUpdateString Of hoJson "invitable_type" "business" To iSuccess
Get ComUpdateInt Of hoJson "groups[0].group_id" 6360979 To iSuccess
Get ComUpdateString Of hoJson "groups[0].capacity" "manager" To iSuccess
Get ComUpdateInt Of hoJson "groups[1].group_id" 6360987 To iSuccess
Get ComUpdateString Of hoJson "groups[1].capacity" "manager" To iSuccess
Get ComUpdateInt Of hoJson "groups[2].group_id" 6360952 To iSuccess
Get ComUpdateString Of hoJson "groups[2].capacity" "manager" To iSuccess
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://api.freshbooks.com/auth/api/v1/users/invitation" "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 "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"capacity": "manager",
"to_email": "yourteammemberemail@freshbooks.com",
"invitable_id": {{businessid}},
"invitable_type": "business",
"groups": [
{
"group_id": 6360979,
"capacity": "manager"
},
{
"group_id": 6360987,
"capacity": "manager"
},
{
"group_id": 6360952,
"capacity": "manager"
}
]
}'
https://api.freshbooks.com/auth/api/v1/users/invitation
Postman Collection Item JSON
{
"name": "Invite Team Member to Project(s)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"capacity\": \"manager\",\n \"to_email\": \"yourteammemberemail@freshbooks.com\",\n \"invitable_id\": {{businessid}},\n \"invitable_type\": \"business\",\n \"groups\": [\n {\n \"group_id\": 6360979,\n \"capacity\": \"manager\"\n },\n {\n \"group_id\": 6360987,\n \"capacity\": \"manager\"\n },\n {\n \"group_id\": 6360952,\n \"capacity\": \"manager\"\n }\n ]\n}"
},
"url": {
"raw": "https://api.freshbooks.com/auth/api/v1/users/invitation",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"auth",
"api",
"v1",
"users",
"invitation"
]
}
},
"response": [
]
}