Chilkat Online Tools

Objective-C / New FreshBooks / Register as a new user

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

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

CkoHttp *http = [[CkoHttp alloc] init];
BOOL 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.

// {
//   "id": "api.freshbooks@gmail.com",
//   "company_name": null,
//   "email": "api.freshbooks@gmail.com",
//   "password": "jjjjjjjjjjjjjjjjjjj",
//   "country": "Canada",
//   "currencyCode": "CAD",
//   "access_token": null,
//   "direct_buy": false,
//   "skip_system": false,
//   "skip_business": false,
//   "send_confirmation_notification": true,
//   "capacity": null,
//   "provisioner": "magnum",
//   "referring_url": null,
//   "landing_url": null,
//   "referralid": null,
//   "web_promo": null,
//   "visitor_id": null,
//   "optimizely_user_id": "oeu1556551964423r0.989078205100306",
//   "optimizely_buckets": null
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"id" value: @"api.freshbooks@gmail.com"];
[json UpdateNull: @"company_name"];
[json UpdateString: @"email" value: @"api.freshbooks@gmail.com"];
[json UpdateString: @"password" value: @"jjjjjjjjjjjjjjjjjjj"];
[json UpdateString: @"country" value: @"Canada"];
[json UpdateString: @"currencyCode" value: @"CAD"];
[json UpdateNull: @"access_token"];
[json UpdateBool: @"direct_buy" value: NO];
[json UpdateBool: @"skip_system" value: NO];
[json UpdateBool: @"skip_business" value: NO];
[json UpdateBool: @"send_confirmation_notification" value: YES];
[json UpdateNull: @"capacity"];
[json UpdateString: @"provisioner" value: @"magnum"];
[json UpdateNull: @"referring_url"];
[json UpdateNull: @"landing_url"];
[json UpdateNull: @"referralid"];
[json UpdateNull: @"web_promo"];
[json UpdateNull: @"visitor_id"];
[json UpdateString: @"optimizely_user_id" value: @"oeu1556551964423r0.989078205100306"];
[json UpdateNull: @"optimizely_buckets"];

[http SetRequestHeader: @"Content-Type" value: @"application/json"];

CkoHttpResponse *resp = [http PostJson3: @"https://api.freshbooks.com/auth/api/v1/smux/registrations" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-d '{
    "id": "api.freshbooks@gmail.com",
    "company_name": null,
    "email": "api.freshbooks@gmail.com",
    "password": "jjjjjjjjjjjjjjjjjjj",
    "country": "Canada",
    "currencyCode": "CAD",
    "access_token": null,
    "direct_buy": false,
    "skip_system": false,
    "skip_business": false,
    "send_confirmation_notification": true,
    "capacity": null,
    "provisioner": "magnum",
    "referring_url": null,
    "landing_url": null,
    "referralid": null,
    "web_promo": null,
    "visitor_id": null,
    "optimizely_user_id": "oeu1556551964423r0.989078205100306",
    "optimizely_buckets": null
}'
https://api.freshbooks.com/auth/api/v1/smux/registrations

Postman Collection Item JSON

{
  "name": "Register as a new user",
  "request": {
    "auth": {
      "type": "noauth"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"id\": \"api.freshbooks@gmail.com\",\n    \"company_name\": null,\n    \"email\": \"api.freshbooks@gmail.com\",\n    \"password\": \"jjjjjjjjjjjjjjjjjjj\",\n    \"country\": \"Canada\",\n    \"currencyCode\": \"CAD\",\n    \"access_token\": null,\n    \"direct_buy\": false,\n    \"skip_system\": false,\n    \"skip_business\": false,\n    \"send_confirmation_notification\": true,\n    \"capacity\": null,\n    \"provisioner\": \"magnum\",\n    \"referring_url\": null,\n    \"landing_url\": null,\n    \"referralid\": null,\n    \"web_promo\": null,\n    \"visitor_id\": null,\n    \"optimizely_user_id\": \"oeu1556551964423r0.989078205100306\",\n    \"optimizely_buckets\": null\n}"
    },
    "url": {
      "raw": "https://api.freshbooks.com/auth/api/v1/smux/registrations",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "auth",
        "api",
        "v1",
        "smux",
        "registrations"
      ]
    }
  },
  "response": [
  ]
}