Foxpro / New FreshBooks / Add Comment to Project Discussion Message
        
        Back to Collection Items
        LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
*   "comment": {
*     "content": "Sounds like a plan!"
*   }
* }
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("comment.content","Sounds like a plan!")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loHttp.SetRequestHeader("Content-Type","application/json")
loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpJson("POST","https://api.freshbooks.com/comments/business/{{businessid}}/threads/{{threadid}}/comments",loJson,"application/json",loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loResp
    CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loHttp
RELEASE loJson
RELEASE loResp
        Curl Command
        curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "comment": {
        "content": "Sounds like a plan!"
    }
}'
https://api.freshbooks.com/comments/business/{{businessid}}/threads/{{threadid}}/comments
        Postman Collection Item JSON
        {
  "name": "Add Comment to Project Discussion Message",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"comment\": {\n        \"content\": \"Sounds like a plan!\"\n    }\n}"
    },
    "url": {
      "raw": "https://api.freshbooks.com/comments/business/{{businessid}}/threads/{{threadid}}/comments",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "comments",
        "business",
        "{{businessid}}",
        "threads",
        "{{threadid}}",
        "comments"
      ]
    },
    "description": "Adds a comment to a project discussion message"
  },
  "response": [
  ]
}