Microsoft C++ REST SDK version 1.0 codename Casablanca is open source project hosted at GitHub, and takes advantage of the new set of capabilities introduced in C++ 11 to simplify cloud-based coding with a modern, asynchronous, and multi-platform API design.

The C++ REST SDK is included with Visual Studio 2013, and is also released as a separate project on github. The github project is updated independently of Visual Studio and might contain updates and features that are not included with Visual Studio. You can install the Visual Studio and github releases side-by-side on the same computer.

The C++ REST SDK is supported on both Visual Studio 2015 and 2017. It provides powerful models to writing asynchronous code based on new C++ 11 features. REST services from any native code written on multiple operating systems can be accessed through C++ SDK.

Here are some of the features of C++ REST SDK:

Programming with Tasks

All the asynchronous APIs in Casablanca are build on the PPL tasks library available as part of Visual Studio 2015. There is also a special version of PPL tasks library available for VS 2010 and Linux.

Platform Independent Strings

Preferred representation of textual data in the form of strings is different depending on the platform. So, in order to write platform independent code, C++ REST SDK defines typedef utility::string_t which corresponds to platform preference.

HTTP Client

In C++ SDK, HTTP client class is used to maintain connection to an HTTP service i.e. web::http::client::http_client. The constructor accepts a string or URI to make the connection with service i.e.

Next is to call request method to make the request i.e.

HTTP Listener

HTTP listener is a C++ object that accepts messages directed at a particular URI. HTTP listeners APIs can be found in the class web::http::experimental::listener. Creating a listener object is same as client i.e.

Asynchronous Streams and Stream Buffers

The concrete implementations of streams buffers are Producer Consumer, File Streams, Container Streams, Raw Pointer Streams, Interop Streams.

JSON

In C++ REST SDK all JSON values are represented by the web::json::value class; it doesn’t matter whether it’s a number, a string, or an object, from a static type perspective.

There’s a value factory function for each of the six types of JSON values. In addition, there are overloads of the functions to create string, object, and array values. Here are some examples of constructing JSON values:

Uniform Resource Identifier (URI)

Uniform resource identifiers (URIs) are, as you probably already know, structured strings that are used to specifically identify various entities in the world. URIs used with HTTP have the following format:

protocol : // server [: port] / path ? query # fragment

The main class is web::http::uri, which represents a fully formed identifier. There is also a web::http::uri_builder class which can be used to incrementally build the URI such as

Linux Features

Almost all of the features listed above are supported on Linux as well i.e. Asynchronous Stream, JSON, URI and URIBuilder andHTTP Client.

Sample Program to connect to an HTTP Server with C++ REST SDK