【发布时间】:2015-08-28 13:03:36
【问题描述】:
我正在尝试将我的应用程序与 mercadolibre API 集成。我可以毫无问题地列出一个新项目,但是当我尝试插入图片数组时,集成不起作用。 错误信息:
{"message":"body.invalid_field_types","error":"[invalid property type: [pictures] expected List but was null value: [pictures:[[source:http://www.nichepursuits.com/wp-content/uploads/2014/02/buy-websites.jpg], [source:http://thumb9.shutterstock.com/display_pic_with_logo/639229/176602316/stock-vector-best-buy-rubber-stamp-red-icon-isolated-on-white-background-vector-illustration-176602316.jpg]]]]","status":400,"cause":[]}
当我尝试使用下面的第二个选项时,Visual Studio 显示编译错误。
我已经测试了很多声明,但都失败了。
暂定1:
IRestResponse r = m.Post("/items", ps, new
{
title = _item.title,
category_id = _item.category_id,
price = _item.price,
currency_id = _item.currency_id,
available_quantity = _item.available_quantity,
buying_mode = _item.buying_mode,
listing_type_id = _item.listing_type_id,
condition = _item.condition,
description = _item.description,
warranty = _item.warranty,
pictures = new {pictures = new []
{
new {source = "http://www.nichepursuits.com/wp-content/uploads/2014/02/buy-websites.jpg"},
new {source = "http://thumb9.shutterstock.com/display_pic_with_logo/639229/176602316/stock-vector-best-buy-rubber-stamp-red-icon-isolated-on-white-background-vector-illustration-176602316.jpg"}
}}
});
暂定 2:
IRestResponse r = m.Post("/items", ps, new
{
title = _item.title,
category_id = _item.category_id,
price = _item.price,
currency_id = _item.currency_id,
available_quantity = _item.available_quantity,
buying_mode = _item.buying_mode,
listing_type_id = _item.listing_type_id,
condition = _item.condition,
description = _item.description,
warranty = _item.warranty,
pictures = [{"Source":"Value"},{"Source":Value2}]
});
【问题讨论】:
-
描述“不工作”。你有错误吗?它怎么不能完成你想要的?
-
嗨,梅森。我已经编辑了这个主题。谢谢。
-
你说现在抛出编译错误,但是你需要解释编译错误是什么。
-
在第一个代码块上
pictures加倍:pictures = new {pictures = new [] ...。试试pictures = new [] .... -
谢谢。解决方案如下。