[英]Using RestSharp to upload an image via Etsy API
我正在尝试通过正在开发的Web应用程序将图像以及新列表添加到我的Etsy帐户中。 目前,我正在使用:
RestRequest request = new RestRequest("listings", Method.POST);
request.AddFile("image", ReadToEnd(o.mainPhoto), "test.bmp", "image/bmp");
request.AddParameter("image", "test.bmp");
request.AddParameter("title", "This is a test");
request.AddParameter("description", "Test Description");
request.AddParameter("status", "draft");
request.AddParameter("quantity", "1");
request.AddParameter("price", "5");
request.AddParameter("is_supply", "false");
request.AddParameter("category_id", "68887420");
request.AddParameter("when_made", "2013");
request.AddParameter("who_made", "i_did");
request.AddParameter("shipping_template_id", 5463224);
var etsyResponse = restClient.Execute<EtsyListing>(request);
清单正确创建,但没有图像。
我注意到etsyResponse的内容包含有关上载图像的信息(即大小,名称等),包括为该图像创建的“ tmp_name”。 我应该将列表与etsyResponse中的“ tmp_name”关联,而不是与文件的上载名称关联吗?
任何帮助表示赞赏。
我实际上只是遇到了完全相同的问题。 我在RestSharp上使用C#服务器端处理程序,以HttpPostedFile实例中的图像数据发布新列表。 清单草稿创建得很好,但是没有任何图像。 就像您提到的那样,我看到了tmp_name和errors值,这些值似乎表明已创建映像。 经过试验后,我最终有效的最终解决方案是:
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.