How to call a Rest Service in C++?
Solution 1
On Linux, you probably could use curl library (and I guess it is ported to Windows). Curl is a library providing HTTP client functionality to a C or C++ program.
Solution 2
Use Casablanca. This should be helpful for people looking for this answer in 2013. CURL is perfectly appropriate but if you're doing C++ in Windows and using MS stuff, Casablanca seems fit.
Solution 3
I tried gsoap myself but it became difficult to maintain cross platform versions of my app. Instead i went the HTTP request route. For cross platform and C++ i found this Call Rest Web Services from C++
Solution 4
Hope the following articles might be of help to you
adnangohar
Updated on June 20, 2022Comments
-
adnangohar almost 2 years
I want to call a rest service written in WCF (which can support both XML and JSON Web Message Formats) from my C++ application.
What is the best solution to achieve this ? I have seen some utilities (gsoap) which create proxy classes for you to be used to call web services.
Can I achieve the same functionality without using any intermediate utility ? As its a rest service and it works using GET/PUT functions which are basic HTTP functions, is there any C++ library/Solution which could be used to invoke these function directly from a c++ application ?
-
pavloskkr over 12 yearsThis sounds sensible to me - CURL is a pretty powerful library for HTTP programming.
-
jstuardo over 7 yearsCasablanca does not seem to work for C++, but only for C++.NET
-
Dalinaum about 6 yearsNo. It also supports macOS, iOS, Linux and Android. github.com/Microsoft/cpprestsdk/wiki
-
pixel over 3 yearsIt works for C++, I am just going through examples and have no issues. VS2017