Assistance de TMDB

All of a sudden I'm having customers complaining about an error every time they try to search for a movie using my program. I haven't changed any code on my end in quite some time. The error when parsing the JSON is "Input string was not in a correct format." When I run a test on apiary the following is shown in red:

"1": The ‘production_countries,1’ property is required. | The production_countries,1 property must be an object (current value is undefined). { "iso_3166_1": "US" The ‘production_countries,1,iso_3166_1’ property is required. "name": "United States of America" The ‘production_countries,1,name’ property is required.

Did something change in the API to cause this? If so, do you have any idea how I can easily fix this? I've created a custom .net dll based off TMDbLib using Newtonsoft.Json instead.

Thanks!

10 réponses (sur la page 1 sur 1)

Jump to last post

No, nothing changed.

Apiary aside, what's that error actually mean? Does it reference an invalid object or key?

Thank you for the response. I basically learn this stuff as I go, so if I seem like a newbie, sorry. Here is what I've got, hopefully you can help!

It is throwing the error here: Movie resp = JsonConvert.DeserializeObject(response, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

Here is my Movie class:


        public bool adult { get; set; }
        public string backdrop_path { get; set; }
        public BelongsToCollection belongs_to_collection { get; set; }
        public Int64 budget { get; set; }
        public List genres { get; set; }
        public string homepage { get; set; }
        public int id { get; set; }
        public string imdb_id { get; set; }
        public string original_title { get; set; }
        public string overview { get; set; }
        public double popularity { get; set; }
        public string poster_path { get; set; }
        public List production_companies { get; set; }
        public List production_countries { get; set; }
        public string release_date { get; set; }
        public Int64 revenue { get; set; }
        public int runtime { get; set; }
        public List spoken_languages { get; set; }
        public string status { get; set; }
        public string tagline { get; set; }
        public string title { get; set; }
        public double vote_average { get; set; }
        public Int64 vote_count { get; set; }
        public AlternativeTitles alternative_titles { get; set; }
        public Casts casts { get; set; }
        public Images images { get; set; }
        public Releases releases { get; set; }
        public SearchContainer lists { get; set; }
        public Trailers trailers { get; set; }
        public TranslationsContainer translations { get; set; }
        public KeywordsContainer keywords { get; set; }
        public SearchContainer similar_movies { get; set; }
        public List changes { get; set; }

I am not sure which one is actually throwing the error. I only brought up production_countries because that is what was in red on apiary. Do you see anything? Like I said, it was working fine for months for everybody using my program, but all of a sudden it isn't working for any search.

If you need any more info, I'd be happy to get it for you. Thanks!

Hi Mark,

Do you have an example search that is throwing the error?

I am wondering if it's the combination poster_path and backdrop_path definitions you have there being set to strings. If no image exists the result is null, not an empty string. I have absolutely zero knowledge about C# but if things are strongly typed like that, the JSON parser could be throwing an error when null comes in expecting to be a string.

Example that is throwing the error:

/3/movie/62211?api_key=[mykey]&append_to_response=alternative_titles,casts,images,releasese,lists

The NullValueHandling = NullValueHandling.Ignore in the JsonSerializerSettings should ignore the nulls so they don't throw an error.

Thanks!

Is that releasese the actual response you're trying to append? That looks like a typo but I'm not clear if it was something that got mucked around pasting it in here or if that's what your code actually says.

I don't see anything else that sticks out though.

Sorry. That was a typo. Ok. I'll do some more messing around to see if I can figure it out. Thanks.

FYI: I figured it out. It looks like the height and width for each of the appended images were no longer integers. For example: the response text shows: "height":1080.0 So it was flipping out when it saw the decimal point. I switched them to parse as a double instead of an integer and it now parses them correctly. Thanks!

Interesting!

I should probably coerce them back to integers, but as long as the change you just made will just with that we're good.

I'll get this fixed up later this afternoon.

Great! Yeah, it would be better on my end if you switch them back to integers so I don't have to send out an update... but like you said, either way will work. Thanks!

Fix for this was pushed about 10 minutes ago but we'll have to wait for all of the already cached items to expire from the cache. Should be fixed for all newly cached items from here on in.

Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.

Général

s Mettre le curseur dans la barre de recherche
p Ouvrir le menu du profil
esc Fermer une fenêtre ouverte
? Ouvrir la fenêtre des raccourcis clavier

Sur les pages des médias

b Retour (ou vers le parent si faisable)
e Afficher la page de modification

Sur les pages des saisons des émissions télévisées

Afficher la saison suivante (flèche droite)
Afficher la saison précédente (flèche gauche)

Sur les pages des épisodes des émissions télévisées

Afficher l'épisode suivant (flèche droite)
Afficher l'épisode précédent (flèche gauche)

Sur toutes les pages des images / photos

a Ouvrir la fenêtre d'ajout d'image / photo

Sur toutes les pages de modifications

t Ouvrir le sélecteur de traduction
ctrl+ s Envoyer le formulaire

Sur les pages des discussions

n Créer une nouvelle discussion
w Basculer le statut de suivi
p Basculer publique / privée
c Basculer fermer / ouvrir
a Ouvrir l'activité
r Répondre à la discussion
l Afficher la dernière réponse
ctrl+ enter Envoyer votre message
Page suivante (flèche droite)
Page précédente (flèche gauche)

Paramètres

Vous souhaitez évaluer ou ajouter cet élément à une liste ?

Connexion