Chilkat Online Tools

Java / New FreshBooks / Resend Verification Code

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

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

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

    // {
    //   "callback": {
    //     "callback_id": 2001,
    //     "resend": true
    //   }
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateInt("callback.callback_id",2001);
    json.UpdateBool("callback.resend",true);

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");
    http.SetRequestHeader("Content-Type","application/json");

    CkStringBuilder sbRequestBody = new CkStringBuilder();
    json.EmitSb(sbRequestBody);

    CkHttpResponse resp = http.PTextSb("PUT","https://api.freshbooks.com/events/account/{{accountId}}/events/callbacks/{{callbackId}}",sbRequestBody,"utf-8","application/json",false,false);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-d '{
    "callback": {
        "callback_id": 2001,
        "resend": true
    }
}'
https://api.freshbooks.com/events/account/{{accountId}}/events/callbacks/{{callbackId}}

Postman Collection Item JSON

{
  "name": "Resend Verification Code",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"callback\": {\n        \"callback_id\": 2001,\n        \"resend\": true\n    }\n}"
    },
    "url": {
      "raw": "https://api.freshbooks.com/events/account/{{accountId}}/events/callbacks/{{callbackId}}",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "events",
        "account",
        "{{accountId}}",
        "events",
        "callbacks",
        "{{callbackId}}"
      ]
    }
  },
  "response": [
  ]
}