Forum Discussion
hugomario
Staff
6 years agodo you think you can share client code or part of the client code used to invoke request ?
pwd
6 years agoOccasional Contributor
Sure - I use a C++ tool using cpprest stubs generated from the same API. The calling code looks as follows (let me know if there are other parts of interest):
std::shared_ptr<ApiConfiguration> apiConfig = std::make_shared<ApiConfiguration>();
apiConfig->setUserAgent("Agent-42");
apiConfig->setBaseUrl("http://XXX:8080/XXX/XXX-backend/1.0");
std::shared_ptr<ApiClient> apiClient = std::make_shared<ApiClient>();
apiClient->setConfiguration(apiConfig);
std::shared_ptr<HostManagementApi> hostMgmtApi = std::make_shared<HostManagementApi>(apiClient);
std::shared_ptr<HostSpec> hs = std::make_shared<HostSpec>();
hs->setHostId(hostID);
pplx::task<std::shared_ptr<Empty_success_response>> requestTask = hostMgmtApi->addHost(hs);
requestTask.then([=](pplx::task<std::shared_ptr<Empty_success_response>> task) {
fprintf(stderr, "Task completed; collecting response...\n");
try
{
std::shared_ptr<Empty_success_response> response = task.get();
}
catch (const std::exception &e)
{
printf("Error exception during task.get(): %s\n", e.what());
}
});