The Movie Database 支持

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 回复(第 1 页,共 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.

找不到电影或剧集?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)前一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区