-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error 404 Fetching JSON data from Movie API #51
Comments
I'll have a look at it |
The url you provide will be encoded, and that will prevent the server from decoding your authentication token. Try SerializeFromJson(movie,
RequestBuilder(ctx)
.Get("http://api.themoviedb.org/3/search/movie")
.Argument("api_key", "30ac911b5a4841e65d905a53b31396ae")
.Argument("query", "Jack+Reacher")
.Header("X-Client", "RESTC_CPP")
.Header("X-Client-Purpose", "Testing")
.Execute()); The Argument() functions will make sure that the arguments are sent correctly. You should 'git pull' restc-cpp, as I found and fixed a bug wen I checked this. |
I have pulled and installed the restc-cpp library and used the code above. However, I am getting an error from SerializeJson.
Edit: It is due to me trying to add the struct of results and it seems to be the wrong way of adding it.
This is what I have for now:
but I am not sure how to edit
|
I would put the results in a structure and then and then add it as: struct Movie {
int page = 0;
int total_results = 0;
int total_pages = 0;
std::vector<Results> results;
}
BOOST_FUSION_ADAPT_STRUCT(
Movie,
(int, page)
(int, total_results)
(int, total_pages)
(std::vector<Results>, results)
) Make sure that Movie has the same member, as you map directly from C++ data-type and name. You can have a look at this header to see some more complex mappings. |
I am getting Process finished with exit code 11 from this
|
I'll take a look |
Since you are serializing Results, you need to declare that as well :) BOOST_FUSION_ADAPT_STRUCT(
Results,
(int, vote_count)
(int, id)
(bool, video)
(double, vote_average)
(string, title)
(double, popularity)
(string, poster_path)
(string, original_language)
(string, original_title)
(bool, adult)
(string, overview)
(string, release_date)
) I have committed an assert for that case, and a fix where restc-cpp needs to ignore an array (genre_ids). So you should 'git poll' before testing again. |
Awesome! Got it to work. Thank you very much. Really appreciate it. :D |
I tried querying other movies such as Titanic and Black Panther and got this exception. |
That's interesting. |
It is the same as above just that I changed .Argument("query", "Jack+Reacher") to .Argument("query", "titanic") Edit: I realised it is because genre_ids and backdrop_path are not set in struct.
I added genre_ids and backdrop_path in struct and it works for query of Jack+Reacher but not spiderman or titanic. It causes the error:
|
I'll take a look at it tomorrow. It might be a bug. |
Did I declare the array genre_ids wrongly? |
I can reproduce it. Trying to figure out what's triggering the error. |
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. |
Great! Really thankful that you made it work. I will be trying to get it to work with Twitter API next, to pull tweets from Twitter. Any idea how to authorize request on twitter API with this library? It should work if I Add_Headers() the following for authentication? |
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. |
Hi, I am trying to fetch movie information from a Movie API. However, I get
trying to do so and wish to know how do I change the struct to fit the API.
E.g.
The text was updated successfully, but these errors were encountered: