restc-cpp: Error 404 Fetching JSON data from Movie API
Hi, I am trying to fetch movie information from a Movie API. However, I get
libc++abi.dylib: terminating with uncaught exception of type restc_cpp::HttpNotFoundException: Request failed with HTTP error: 404 Not Found
trying to do so and wish to know how do I change the struct to fit the API.
E.g.

#include <iostream>
#include <boost/lexical_cast.hpp>
#include <boost/fusion/adapted.hpp>
#include "restc-cpp/restc-cpp.h"
#include "restc-cpp/RequestBuilder.h"
using namespace std;
using namespace restc_cpp;
struct Movie {
    int page = 0;
    int total_results = 0;
    int total_pages = 0;
};
BOOST_FUSION_ADAPT_STRUCT(
        Movie,
        (int, page)
        (int, total_results)
        (int, total_pages)
)
int main() {
    auto rest_client = RestClient::Create();
    Movie found_movies = rest_client->ProcessWithPromiseT<Movie>([&](Context& ctx) {
                
                Movie movie;
                SerializeFromJson(movie,
                                  RequestBuilder(ctx)
                                          .Get("https://api.themoviedb.org/3/search/movie?api_key=30ac911b5a4841e65d905a53b31396ae&query=Jack+Reacher")
                                          .Header("X-Client", "RESTC_CPP")
                                          .Header("X-Client-Purpose", "Testing")
                                          .Execute());
                return movie;
            }).get();
    cout << "Number of Results " << found_movies.total_results << ", Page: " << found_movies.page << endl;
}
About this issue
- Original URL
 - State: closed
 - Created 6 years ago
 - Comments: 17 (10 by maintainers)
 
You found another bug! I have committed a fix.
This list could actually be implemented as an iterator, where you loop over the content. That would allow huge result-sets. I have implemented that for one project, and been thinking about doing it in a more general fashion. If I get time in the near future, I’ll see if I can use this movie API as one of the examples for such a general feature.
Thank you for digging out these bugs btw. If this was a commercial project there would have been a QA person spending considerable time figuring out how to crash the library - but with free, open source, I have to relay on my own imagination and real life cases reported by users.
I don’t really understand why these services keeps using OAuth. It’s been broken (insecure) for a long time.
Anyway, using it requires cryptographic signing of headers and content in a very specific way. I think it should be done by restc-cpp as the process is complex and will take time to comprehend an implement. It’s documented here: https://developer.twitter.com/en/docs/basics/authentication/guides/authorizing-a-request
The general OAuth 1.0 protocol is documented here: https://oauth.net/core/1.0/#anchor9
I don’t have time to implement this right away, but I’ll put it on my list.