Chilkat  HOME  Android™  Classic ASP  C  C++  C#  Mono C#  .NET Core C#  C# UWP/WinRT  DataFlex  Delphi ActiveX  Delphi DLL  Visual FoxPro  Java  Lianja  MFC  Objective-C  Perl  PHP ActiveX  PHP Extension  PowerBuilder  PowerShell  PureBasic  CkPython  Chilkat2-Python  Ruby  SQL Server  Swift 2  Swift 3,4,5...  Tcl  Unicode C  Unicode C++  Visual Basic 6.0  VB.NET  VB.NET UWP/WinRT  VBScript  Xojo Plugin  Node.js  Excel  Go
 
      (MFC) Yousign Create Procedure after Uploading the PDFDemonstrates the 2nd step of Yousign procedure creation. This is the call to create the procedure after previously uploading the PDF file. For more information, see https://dev.yousign.com/?version=latest#c2e03a8b-f782-4d3e-96d1-04517c083497 
 #include <CkHttp.h> #include <CkJsonObject.h> #include <CkHttpResponse.h> #include <CkStringBuilder.h> void ChilkatSample(void) { CkString strOut; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; bool success; // Implements the following CURL command: // curl --location --request POST 'https://staging-api.yousign.com/procedures' \ // --header 'Authorization: Bearer YOUR_API_KEY' \ // --header 'Content-Type: application/json' \ // --data-raw '{ // "name": "My first procedure", // "description": "Awesome! Here is the description of my first procedure", // "members": [ // { // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "fileObjects": [ // { // "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "page": 2, // "position": "230,499,464,589", // "mention": "Read and approved", // "mention2": "Signed by John Doe" // } // ] // } // ] // }' // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // 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 procedure", // "description": "Awesome! Here is the description of my first procedure", // "members": [ // { // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "fileObjects": [ // { // "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "page": 2, // "position": "230,499,464,589", // "mention": "Read and approved", // "mention2": "Signed by John Doe" // } // ] // } // ] // } CkJsonObject json; json.UpdateString("name","My first procedure"); json.UpdateString("description","Awesome! Here is the description of my first procedure"); json.UpdateString("members[0].firstname","John"); json.UpdateString("members[0].lastname","Doe"); json.UpdateString("members[0].email","john.doe@yousign.fr"); json.UpdateString("members[0].phone","+33612345678"); json.UpdateString("members[0].fileObjects[0].file","/files/6c123a8d-e5cf-4534-8da0-81886376ba2c"); json.UpdateInt("members[0].fileObjects[0].page",2); json.UpdateString("members[0].fileObjects[0].position","230,499,464,589"); json.UpdateString("members[0].fileObjects[0].mention","Read and approved"); json.UpdateString("members[0].fileObjects[0].mention2","Signed by John Doe"); // Adds the "Authorization: Bearer YOUR_API_KEY" header. http.put_AuthToken("YOUR_API_KEY"); http.SetRequestHeader("Content-Type","application/json"); CkHttpResponse *resp = http.PostJson3("https://staging-api.yousign.com/procedures","application/json",json); if (http.get_LastMethodSuccess() == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkStringBuilder sbResponseBody; resp->GetBodySb(sbResponseBody); CkJsonObject jResp; jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); strOut.append("Response Body:"); strOut.append("\r\n"); strOut.append(jResp.emit()); strOut.append("\r\n"); int respStatusCode = resp->get_StatusCode(); strOut.append("Response Status Code = "); strOut.appendInt(respStatusCode); strOut.append("\r\n"); if (respStatusCode >= 400) { strOut.append("Response Header:"); strOut.append("\r\n"); strOut.append(resp->header()); strOut.append("\r\n"); strOut.append("Failed."); strOut.append("\r\n"); delete resp; SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } delete resp; // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "id": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "My first procedure", // "description": "Awesome! Here is the description of my first procedure", // "createdAt": "2018-12-01T11:49:11+01:00", // "updatedAt": "2018-12-01T11:49:11+01:00", // "finishedAt": null, // "expiresAt": null, // "status": "active", // "creator": null, // "creatorFirstName": null, // "creatorLastName": null, // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "template": false, // "ordered": false, // "parent": null, // "metadata": [ // ], // "config": [ // ], // "members": [ // { // "id": "/members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "user": null, // "type": "signer", // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "position": 1, // "createdAt": "2018-12-01T11:49:11+01:00", // "updatedAt": "2018-12-01T11:49:11+01:00", // "finishedAt": null, // "status": "pending", // "fileObjects": [ // { // "id": "/file_objects/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "file": { // "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "The best name for my file.pdf", // "type": "signable", // "contentType": "application/pdf", // "description": null, // "createdAt": "2018-12-01T11:36:20+01:00", // "updatedAt": "2018-12-01T11:49:11+01:00", // "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", // "metadata": [ // ], // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "creator": null, // "protected": false, // "position": 0, // "parent": null // }, // "page": 2, // "position": "230,499,464,589", // "fieldName": null, // "mention": "Read and approved", // "mention2": "Signed by John Doe", // "createdAt": "2018-12-01T11:49:11+01:00", // "updatedAt": "2018-12-01T11:49:11+01:00", // "parent": null, // "reason": "Signed by Yousign" // } // ], // "comment": null, // "notificationsEmail": [ // ], // "operationLevel": "custom", // "operationCustomModes": [ // "sms" // ], // "operationModeSmsConfig": null, // "parent": null // } // ], // "subscribers": [ // ], // "files": [ // { // "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "The best name for my file.pdf", // "type": "signable", // "contentType": "application/pdf", // "description": null, // "createdAt": "2018-12-01T11:36:20+01:00", // "updatedAt": "2018-12-01T11:49:11+01:00", // "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", // "metadata": [ // ], // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "creator": null, // "protected": false, // "position": 0, // "parent": null // } // ], // "relatedFilesEnable": false, // "archive": false, // "archiveMetadata": [ // ], // "fields": [ // ], // "permissions": [ // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const char *user = 0; const char *v_type = 0; const char *firstname = 0; const char *lastname = 0; const char *email = 0; const char *phone = 0; int position; const char *comment = 0; const char *operationLevel = 0; const char *operationModeSmsConfig = 0; int j; int count_j; const char *fileId = 0; const char *fileName = 0; const char *fileType = 0; const char *fileContentType = 0; const char *fileDescription = 0; const char *fileCreatedAt = 0; const char *fileUpdatedAt = 0; const char *fileSha256 = 0; const char *fileWorkspace = 0; const char *fileCreator = 0; bool fileProtected; int filePosition; const char *fileParent = 0; int page; const char *position_str = 0; const char *fieldName = 0; const char *mention = 0; const char *mention2 = 0; const char *reason = 0; int k; int count_k; const char *strVal = 0; const char *contentType = 0; const char *sha256 = 0; bool v_protected; const char *id = jResp.stringOf("id"); const char *name = jResp.stringOf("name"); const char *description = jResp.stringOf("description"); const char *createdAt = jResp.stringOf("createdAt"); const char *updatedAt = jResp.stringOf("updatedAt"); const char *finishedAt = jResp.stringOf("finishedAt"); const char *expiresAt = jResp.stringOf("expiresAt"); const char *status = jResp.stringOf("status"); const char *creator = jResp.stringOf("creator"); const char *creatorFirstName = jResp.stringOf("creatorFirstName"); const char *creatorLastName = jResp.stringOf("creatorLastName"); const char *workspace = jResp.stringOf("workspace"); bool template = jResp.BoolOf("template"); bool ordered = jResp.BoolOf("ordered"); const char *parent = jResp.stringOf("parent"); bool relatedFilesEnable = jResp.BoolOf("relatedFilesEnable"); bool archive = jResp.BoolOf("archive"); int i = 0; int count_i = jResp.SizeOfArray("metadata"); while (i < count_i) { jResp.put_I(i); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("config"); while (i < count_i) { jResp.put_I(i); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("members"); while (i < count_i) { jResp.put_I(i); id = jResp.stringOf("members[i].id"); user = jResp.stringOf("members[i].user"); v_type = jResp.stringOf("members[i].type"); firstname = jResp.stringOf("members[i].firstname"); lastname = jResp.stringOf("members[i].lastname"); email = jResp.stringOf("members[i].email"); phone = jResp.stringOf("members[i].phone"); position = jResp.IntOf("members[i].position"); createdAt = jResp.stringOf("members[i].createdAt"); updatedAt = jResp.stringOf("members[i].updatedAt"); finishedAt = jResp.stringOf("members[i].finishedAt"); status = jResp.stringOf("members[i].status"); comment = jResp.stringOf("members[i].comment"); operationLevel = jResp.stringOf("members[i].operationLevel"); operationModeSmsConfig = jResp.stringOf("members[i].operationModeSmsConfig"); parent = jResp.stringOf("members[i].parent"); j = 0; count_j = jResp.SizeOfArray("members[i].fileObjects"); while (j < count_j) { jResp.put_J(j); id = jResp.stringOf("members[i].fileObjects[j].id"); fileId = jResp.stringOf("members[i].fileObjects[j].file.id"); fileName = jResp.stringOf("members[i].fileObjects[j].file.name"); fileType = jResp.stringOf("members[i].fileObjects[j].file.type"); fileContentType = jResp.stringOf("members[i].fileObjects[j].file.contentType"); fileDescription = jResp.stringOf("members[i].fileObjects[j].file.description"); fileCreatedAt = jResp.stringOf("members[i].fileObjects[j].file.createdAt"); fileUpdatedAt = jResp.stringOf("members[i].fileObjects[j].file.updatedAt"); fileSha256 = jResp.stringOf("members[i].fileObjects[j].file.sha256"); fileWorkspace = jResp.stringOf("members[i].fileObjects[j].file.workspace"); fileCreator = jResp.stringOf("members[i].fileObjects[j].file.creator"); fileProtected = jResp.BoolOf("members[i].fileObjects[j].file.protected"); filePosition = jResp.IntOf("members[i].fileObjects[j].file.position"); fileParent = jResp.stringOf("members[i].fileObjects[j].file.parent"); page = jResp.IntOf("members[i].fileObjects[j].page"); position_str = jResp.stringOf("members[i].fileObjects[j].position"); fieldName = jResp.stringOf("members[i].fileObjects[j].fieldName"); mention = jResp.stringOf("members[i].fileObjects[j].mention"); mention2 = jResp.stringOf("members[i].fileObjects[j].mention2"); createdAt = jResp.stringOf("members[i].fileObjects[j].createdAt"); updatedAt = jResp.stringOf("members[i].fileObjects[j].updatedAt"); parent = jResp.stringOf("members[i].fileObjects[j].parent"); reason = jResp.stringOf("members[i].fileObjects[j].reason"); k = 0; count_k = jResp.SizeOfArray("members[i].fileObjects[j].file.metadata"); while (k < count_k) { jResp.put_K(k); k = k + 1; } j = j + 1; } j = 0; count_j = jResp.SizeOfArray("members[i].notificationsEmail"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("members[i].operationCustomModes"); while (j < count_j) { jResp.put_J(j); strVal = jResp.stringOf("members[i].operationCustomModes[j]"); j = j + 1; } i = i + 1; } i = 0; count_i = jResp.SizeOfArray("subscribers"); while (i < count_i) { jResp.put_I(i); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("files"); while (i < count_i) { jResp.put_I(i); id = jResp.stringOf("files[i].id"); name = jResp.stringOf("files[i].name"); v_type = jResp.stringOf("files[i].type"); contentType = jResp.stringOf("files[i].contentType"); description = jResp.stringOf("files[i].description"); createdAt = jResp.stringOf("files[i].createdAt"); updatedAt = jResp.stringOf("files[i].updatedAt"); sha256 = jResp.stringOf("files[i].sha256"); workspace = jResp.stringOf("files[i].workspace"); creator = jResp.stringOf("files[i].creator"); v_protected = jResp.BoolOf("files[i].protected"); position = jResp.IntOf("files[i].position"); parent = jResp.stringOf("files[i].parent"); j = 0; count_j = jResp.SizeOfArray("files[i].metadata"); while (j < count_j) { jResp.put_J(j); j = j + 1; } i = i + 1; } i = 0; count_i = jResp.SizeOfArray("archiveMetadata"); while (i < count_i) { jResp.put_I(i); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("fields"); while (i < count_i) { jResp.put_I(i); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("permissions"); while (i < count_i) { jResp.put_I(i); i = i + 1; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); }  | 
  ||||
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.