Can somebody help me resolve this issue which I am getting on invoking REST API
====
// NutanixCommvaultsample.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/http_listener.h> // HTTP server
#include <cpprest/json.h> // JSON library
#include <cpprest/uri.h> // URI library
#include <cpprest/ws_client.h> // WebSocket client
#include <cpprest/containerstream.h> // Async streams backed by STL containers
#include <cpprest/interopstream.h> // Bridges for integrating Async streams with STL and WinRT streams
#include <cpprest/rawptrstream.h> // Async streams backed by raw pointer to memory
#include <cpprest/producerconsumerstream.h> // Async streams for producer consumer scenarios
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
using namespace web::http::experimental::listener; // HTTP server
using namespace web::experimental::web_sockets::client; // WebSockets client
using namespace web::json; // JSON library
// Asynchrously make a resuest to Nutanix Prism Rest API to get the list of snapshots and store the response in a file
// Begin main
int main(int argc, char* argv[])
{
printf("2");
//set credentials
http_client_config config1;
printf("3");
credentials cred = credentials(U("admin"), U("admin"));
printf("4");
config1.set_credentials(cred);
//set method
// ## http_client ## Use http_client to create a connection to HTTP service
// The client constructor either accepts a string or a URI
printf("5");
http_client session(U("https://10.11.1.152:9440"), config1);
printf("6");
http_request request;
printf("7");
//set method
request.set_method(methods::GET);
printf("8");
// ## URI ## - Uniform request identifiers that are used for defining entities based on the context . In the case of HTTPS and REST , URI will be used to
// identify the protocol , the server , port , parameters
// URI format --- > protocol : // server [: port] / path ? query # fragment
// Example web::uri_builder builder;
// Example builder.set_query(U("key1=val1"));
// Example builder.set_fragment(U("last"));
// Example uri_builder builder(U("https://10.11.1.152:9440/"));
// Exampke builder.set_path(U("PrismGateway/services/rest/v1/protection_domains/snapshots/"));
request.set_request_uri(uri(U("/PrismGateway/services/rest/v1/protection_domains/snapshots/")));
printf("9");
//request.set_body("application/json"); - To be used only for PUT
printf("10");
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
printf("10");
http_response response = session.request(request).get();
//auto error = GetLastError(); "
printf("12");
}
catch (std::exception& e)
{
printf(e.what());
}
}
====
// NutanixCommvaultsample.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/http_listener.h> // HTTP server
#include <cpprest/json.h> // JSON library
#include <cpprest/uri.h> // URI library
#include <cpprest/ws_client.h> // WebSocket client
#include <cpprest/containerstream.h> // Async streams backed by STL containers
#include <cpprest/interopstream.h> // Bridges for integrating Async streams with STL and WinRT streams
#include <cpprest/rawptrstream.h> // Async streams backed by raw pointer to memory
#include <cpprest/producerconsumerstream.h> // Async streams for producer consumer scenarios
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
using namespace web::http::experimental::listener; // HTTP server
using namespace web::experimental::web_sockets::client; // WebSockets client
using namespace web::json; // JSON library
// Asynchrously make a resuest to Nutanix Prism Rest API to get the list of snapshots and store the response in a file
// Begin main
int main(int argc, char* argv[])
{
printf("2");
//set credentials
http_client_config config1;
printf("3");
credentials cred = credentials(U("admin"), U("admin"));
printf("4");
config1.set_credentials(cred);
//set method
// ## http_client ## Use http_client to create a connection to HTTP service
// The client constructor either accepts a string or a URI
printf("5");
http_client session(U("https://10.11.1.152:9440"), config1);
printf("6");
http_request request;
printf("7");
//set method
request.set_method(methods::GET);
printf("8");
// ## URI ## - Uniform request identifiers that are used for defining entities based on the context . In the case of HTTPS and REST , URI will be used to
// identify the protocol , the server , port , parameters
// URI format --- > protocol : // server [: port] / path ? query # fragment
// Example web::uri_builder builder;
// Example builder.set_query(U("key1=val1"));
// Example builder.set_fragment(U("last"));
// Example uri_builder builder(U("https://10.11.1.152:9440/"));
// Exampke builder.set_path(U("PrismGateway/services/rest/v1/protection_domains/snapshots/"));
request.set_request_uri(uri(U("/PrismGateway/services/rest/v1/protection_domains/snapshots/")));
printf("9");
//request.set_body("application/json"); - To be used only for PUT
printf("10");
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
printf("10");
http_response response = session.request(request).get();
//auto error = GetLastError(); "
printf("12");
}
catch (std::exception& e)
{
printf(e.what());
}
}