Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Cerved API Advanced Entity SearchThe "Advanced Entity Search" API allows you to find subjects in the Cerved database that meet specific search criteria, specified through the parameters provided as input to the service. For more information, see https://apps-developer.cerved.com/
#include <C_CkHttp.h> #include <C_CkJsonObject.h> #include <C_CkHttpResponse.h> #include <C_CkStringBuilder.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkJsonObject json; HCkHttpResponse resp; HCkStringBuilder sbResponseBody; HCkJsonObject jResp; int respStatusCode; const char *subject_id; const char *subject_type; const char *tax_code; const char *addressStreetDescription; const char *addressCityCode; const char *addressCityIstat_code; const char *addressCityDescription; const char *addressProvinceCode; const char *addressProvinceDescription; const char *addressPostal_code; const char *addressCountryCode; const char *addressCountryDescription; const char *company_infoLegal_formCode; const char *company_infoLegal_formDescription; const char *company_infoLegal_formClass_code; const char *company_infoActivity_statusCode; const char *company_infoActivity_statusDescription; const char *company_infoBusiness_name; const char *company_infoEconomic_activityAtecoCode; const char *company_infoEconomic_activityAtecoDescription; const char *company_infoHead_office; const char *company_infoLei_code; const char *company_infoOperational_flag; const char *company_infoPublic_administrationPa_subject; const char *company_infoPublic_administrationPa_supplier; const char *company_infoPublic_administrationPa_owned; const char *company_infoRea_codeCciaa; int company_infoRea_codeRea_number; const char *company_infoRea_codeRegistration_date; const char *company_infoVat_number; const char *company_infoNo_rea_dataForm_code; const char *company_infoNo_rea_dataForm_description; const char *person_infoFirst_name; const char *person_infoLast_name; const char *person_infoName; const char *person_infoBirth_date; const char *person_infoBirth_placeStreetDescription; const char *person_infoBirth_placeCityCode; const char *person_infoBirth_placeCityIstat_code; const char *person_infoBirth_placeCityDescription; const char *person_infoBirth_placeProvinceCode; const char *person_infoBirth_placeProvinceDescription; const char *person_infoBirth_placePostal_code; const char *person_infoBirth_placeCountryCode; const char *person_infoBirth_placeCountryDescription; int subjects_total_number; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); // Implements the following CURL command: // curl -X POST \ // https://api.cerved.com/cervedApi/v1/entitySearch/advanced \ // -H 'accept: application/json' \ // -H 'apikey: ********************************' \ // -d '{ // "search_text": "string", // "activity_status_codes": [ // "A", // "C", // "D", // "F", // "I", // "L", // "N", // "P", // "R", // "S", // "T" // ], // "birth_date": "string", // "name": "string", // "subject_types": [ // "PERSON", // "INDIVIDUAL_COMPANY", // "COMPANY", // "FOREIGN", // "OTHER" // ], // "tax_code": "string", // "vat_number": "string", // "rea": { // "cciaa": "string", // "rea_number": 0 // }, // "city_istat_code": "string", // "province_code": "string" // }' // 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. // { // "search_text": "string", // "activity_status_codes": [ // "A", // "C", // "D", // "F", // "I", // "L", // "N", // "P", // "R", // "S", // "T" // ], // "birth_date": "string", // "name": "string", // "subject_types": [ // "PERSON", // "INDIVIDUAL_COMPANY", // "COMPANY", // "FOREIGN", // "OTHER" // ], // "tax_code": "string", // "vat_number": "string", // "rea": { // "cciaa": "string", // "rea_number": 0 // }, // "city_istat_code": "string", // "province_code": "string" // } json = CkJsonObject_Create(); // IMPORTANT: Only include the lines for the search criteria you wish to include. CkJsonObject_UpdateString(json,"search_text","string"); CkJsonObject_UpdateString(json,"activity_status_codes[0]","A"); CkJsonObject_UpdateString(json,"activity_status_codes[1]","C"); CkJsonObject_UpdateString(json,"activity_status_codes[2]","D"); CkJsonObject_UpdateString(json,"activity_status_codes[3]","F"); CkJsonObject_UpdateString(json,"activity_status_codes[4]","I"); CkJsonObject_UpdateString(json,"activity_status_codes[5]","L"); CkJsonObject_UpdateString(json,"activity_status_codes[6]","N"); CkJsonObject_UpdateString(json,"activity_status_codes[7]","P"); CkJsonObject_UpdateString(json,"activity_status_codes[8]","R"); CkJsonObject_UpdateString(json,"activity_status_codes[9]","S"); CkJsonObject_UpdateString(json,"activity_status_codes[10]","T"); CkJsonObject_UpdateString(json,"birth_date","string"); CkJsonObject_UpdateString(json,"name","string"); CkJsonObject_UpdateString(json,"subject_types[0]","PERSON"); CkJsonObject_UpdateString(json,"subject_types[1]","INDIVIDUAL_COMPANY"); CkJsonObject_UpdateString(json,"subject_types[2]","COMPANY"); CkJsonObject_UpdateString(json,"subject_types[3]","FOREIGN"); CkJsonObject_UpdateString(json,"subject_types[4]","OTHER"); CkJsonObject_UpdateString(json,"tax_code","string"); CkJsonObject_UpdateString(json,"vat_number","string"); CkJsonObject_UpdateString(json,"rea.cciaa","string"); CkJsonObject_UpdateInt(json,"rea.rea_number",0); CkJsonObject_UpdateString(json,"city_istat_code","string"); CkJsonObject_UpdateString(json,"province_code","string"); CkHttp_SetRequestHeader(http,"accept","application/json"); CkHttp_SetRequestHeader(http,"apikey","********************************"); resp = CkHttp_PostJson3(http,"https://api.cerved.com/cervedApi/v1/entitySearch/advanced","application/json",json); if (CkHttp_getLastMethodSuccess(http) == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkJsonObject_Dispose(json); return; } sbResponseBody = CkStringBuilder_Create(); CkHttpResponse_GetBodySb(resp,sbResponseBody); jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(jResp)); respStatusCode = CkHttpResponse_getStatusCode(resp); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttpResponse_header(resp)); printf("Failed.\n"); CkHttpResponse_Dispose(resp); CkHttp_Dispose(http); CkJsonObject_Dispose(json); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); return; } CkHttpResponse_Dispose(resp); // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "subjects": [ // { // "subject_id": "string", // "subject_type": "string", // "tax_code": "string", // "address": { // "street": { // "description": "string" // }, // "city": { // "code": "string", // "istat_code": "string", // "description": "string" // }, // "province": { // "code": "string", // "description": "string" // }, // "postal_code": "string", // "country": { // "code": "string", // "description": "string" // } // }, // "company_info": { // "legal_form": { // "code": "string", // "description": "string", // "class_code": "string" // }, // "activity_status": { // "code": "string", // "description": "string" // }, // "business_name": "string", // "economic_activity": { // "ateco": { // "code": "string", // "description": "string" // } // }, // "head_office": "true", // "lei_code": "string", // "operational_flag": "true", // "public_administration": { // "pa_subject": "true", // "pa_supplier": "true", // "pa_owned": "true" // }, // "rea_code": { // "cciaa": "string", // "rea_number": 0, // "registration_date": "string" // }, // "vat_number": "string", // "no_rea_data": { // "form_code": "string", // "form_description": "string" // } // }, // "person_info": { // "first_name": "string", // "last_name": "string", // "name": "string", // "birth_date": "string", // "birth_place": { // "street": { // "description": "string" // }, // "city": { // "code": "string", // "istat_code": "string", // "description": "string" // }, // "province": { // "code": "string", // "description": "string" // }, // "postal_code": "string", // "country": { // "code": "string", // "description": "string" // } // } // } // } // ], // "subjects_total_number": 0 // } // 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. subjects_total_number = CkJsonObject_IntOf(jResp,"subjects_total_number"); i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"subjects"); while (i < count_i) { CkJsonObject_putI(jResp,i); subject_id = CkJsonObject_stringOf(jResp,"subjects[i].subject_id"); subject_type = CkJsonObject_stringOf(jResp,"subjects[i].subject_type"); tax_code = CkJsonObject_stringOf(jResp,"subjects[i].tax_code"); addressStreetDescription = CkJsonObject_stringOf(jResp,"subjects[i].address.street.description"); addressCityCode = CkJsonObject_stringOf(jResp,"subjects[i].address.city.code"); addressCityIstat_code = CkJsonObject_stringOf(jResp,"subjects[i].address.city.istat_code"); addressCityDescription = CkJsonObject_stringOf(jResp,"subjects[i].address.city.description"); addressProvinceCode = CkJsonObject_stringOf(jResp,"subjects[i].address.province.code"); addressProvinceDescription = CkJsonObject_stringOf(jResp,"subjects[i].address.province.description"); addressPostal_code = CkJsonObject_stringOf(jResp,"subjects[i].address.postal_code"); addressCountryCode = CkJsonObject_stringOf(jResp,"subjects[i].address.country.code"); addressCountryDescription = CkJsonObject_stringOf(jResp,"subjects[i].address.country.description"); company_infoLegal_formCode = CkJsonObject_stringOf(jResp,"subjects[i].company_info.legal_form.code"); company_infoLegal_formDescription = CkJsonObject_stringOf(jResp,"subjects[i].company_info.legal_form.description"); company_infoLegal_formClass_code = CkJsonObject_stringOf(jResp,"subjects[i].company_info.legal_form.class_code"); company_infoActivity_statusCode = CkJsonObject_stringOf(jResp,"subjects[i].company_info.activity_status.code"); company_infoActivity_statusDescription = CkJsonObject_stringOf(jResp,"subjects[i].company_info.activity_status.description"); company_infoBusiness_name = CkJsonObject_stringOf(jResp,"subjects[i].company_info.business_name"); company_infoEconomic_activityAtecoCode = CkJsonObject_stringOf(jResp,"subjects[i].company_info.economic_activity.ateco.code"); company_infoEconomic_activityAtecoDescription = CkJsonObject_stringOf(jResp,"subjects[i].company_info.economic_activity.ateco.description"); company_infoHead_office = CkJsonObject_stringOf(jResp,"subjects[i].company_info.head_office"); company_infoLei_code = CkJsonObject_stringOf(jResp,"subjects[i].company_info.lei_code"); company_infoOperational_flag = CkJsonObject_stringOf(jResp,"subjects[i].company_info.operational_flag"); company_infoPublic_administrationPa_subject = CkJsonObject_stringOf(jResp,"subjects[i].company_info.public_administration.pa_subject"); company_infoPublic_administrationPa_supplier = CkJsonObject_stringOf(jResp,"subjects[i].company_info.public_administration.pa_supplier"); company_infoPublic_administrationPa_owned = CkJsonObject_stringOf(jResp,"subjects[i].company_info.public_administration.pa_owned"); company_infoRea_codeCciaa = CkJsonObject_stringOf(jResp,"subjects[i].company_info.rea_code.cciaa"); company_infoRea_codeRea_number = CkJsonObject_IntOf(jResp,"subjects[i].company_info.rea_code.rea_number"); company_infoRea_codeRegistration_date = CkJsonObject_stringOf(jResp,"subjects[i].company_info.rea_code.registration_date"); company_infoVat_number = CkJsonObject_stringOf(jResp,"subjects[i].company_info.vat_number"); company_infoNo_rea_dataForm_code = CkJsonObject_stringOf(jResp,"subjects[i].company_info.no_rea_data.form_code"); company_infoNo_rea_dataForm_description = CkJsonObject_stringOf(jResp,"subjects[i].company_info.no_rea_data.form_description"); person_infoFirst_name = CkJsonObject_stringOf(jResp,"subjects[i].person_info.first_name"); person_infoLast_name = CkJsonObject_stringOf(jResp,"subjects[i].person_info.last_name"); person_infoName = CkJsonObject_stringOf(jResp,"subjects[i].person_info.name"); person_infoBirth_date = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_date"); person_infoBirth_placeStreetDescription = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.street.description"); person_infoBirth_placeCityCode = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.city.code"); person_infoBirth_placeCityIstat_code = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.city.istat_code"); person_infoBirth_placeCityDescription = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.city.description"); person_infoBirth_placeProvinceCode = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.province.code"); person_infoBirth_placeProvinceDescription = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.province.description"); person_infoBirth_placePostal_code = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.postal_code"); person_infoBirth_placeCountryCode = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.country.code"); person_infoBirth_placeCountryDescription = CkJsonObject_stringOf(jResp,"subjects[i].person_info.birth_place.country.description"); i = i + 1; } CkHttp_Dispose(http); CkJsonObject_Dispose(json); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.