none
C++ Should I use REST or CURL RRS feed

  • Question

  • Should I use REST or CURL to access the internet based APIs from C++?

    I'm trying to interface to ShipEngine.com. I'm told they have a REST interface, which I planned on using, but all their examples use CURL. I don't know much about CURL. I thought REST was built into C++ after version 11 (I'm using visual studio 2019), so I thought that was a good choice. Is CURL becoming the best way to interface to the web?

    I ran some REST tests using Powershell. It seem to get the data OK, but need to processes it and return it to the calling program.

    I'm hoping after the API call to get the outputed data via a JSON object or some other way, so I can pull out the data I want and put it into a character buffer in order to return it to the calling program.

    Once I figure out the best way to call an API and return the data, I plan on creating a standard. Any advice in this area would be much appreciated.

    Tuesday, October 29, 2019 10:29 PM

All replies

  • Hi,

    Thank you for posting here.

    >>Should I use REST or CURL to access the internet based APIs from C++?

    REST is an architectural design style used in implementing web services, while curl is used in command lines or scripts to transfer data, one of which is HTTP/S which is commonly used for accessing REST systems. As far as I'm concerned , C++ does not have any built-in network support. If the system you want to interact with has a REST interface, then you can use cURL (or any other HTTP/S library) to access it.

    Best Regards,

    Jeanine Zhang

    Wednesday, October 30, 2019 8:18 AM
    Moderator
  • Thanks for your reply Jeanine:

    So which http(s) library is preferred in VC++?  

    I remember Casablanca which became the Microsoft REST SDK, which I thought was built into VC++ after version .11.  

    When I look at cURL, it requires a separate Visual Studio installation.  By vs2019, I assumed the http(s) commands were already included in VC++.  

    I guess my question should have been what is the best/prefferred http(s) manager?

    You say VC++ has no built in network support?  Really?  It's built into Powershell, how could it not be build in with VC++?  I'm a mainframe guy where all the tools I need are built into the language or included at link time.

    Thanks for your help,

    Wednesday, October 30, 2019 3:35 PM
  • I'm a mainframe guy where all the tools I need are built into the language or included at link time.

    No they are not built into the language. And I am also a mainframe guy with about 14 years experience with COBOL. I began back in the days of keypunch cards.

    As for at link time, that can allow use of libraries from anywhere, the same as for C++ today.



    Sam Hobbs
    SimpleSamples.Info


    Wednesday, October 30, 2019 4:53 PM
  • I use WinHTTP to automate requests (with REST like OneDrive API or other)


    • Edited by Castorix31 Wednesday, October 30, 2019 6:09 PM
    Wednesday, October 30, 2019 4:55 PM
  • Curl is essentially a command-line tool. It is not a protocol or even a standard. There is libcurl but I suggest that you use something else in the Windows environment. Curl can use many protocols, not just HTTP or FTP.

    REST is also not a standard. It uses a combination of standards, such as HTTP and JSON. Apparently there have been attempts to standardize it but that has not yet been done. Rest nearly always uses HTTP to transfer data.

    You should do some research. The internet is a wonderful resource that you should learn to use. For example see:

    I think that GitHub - microsoft/cpprestsdk is something you can use. Look in the Release folder for samples.



    Sam Hobbs
    SimpleSamples.Info


    Wednesday, October 30, 2019 5:33 PM