【发布时间】:2014-03-12 13:21:23
【问题描述】:
我正在尝试测试对我的一个函数的调用。
这是从我的网站外部调用的,其行为类似于 Web 服务。
测试我试图通过我的网址传递参数。
http://localhost:0000/APIService/UploadValuationDetails?ValuationDetails=[{property_details_address_address1{TagValue:'Test'},{ImageBase64:''}}]?Id=4785
我的服务代码:
public void UploadValuationDetails(Dictionary<string, ValuationDetails> JsonResult, int Id)
{
DatabaseHelper DBH = new DatabaseHelper();
foreach (var item in JsonResult)
{ //(ValuationId , TagName , TagValue , ImageBase64)
DBH.WSValuationDetailUpdate(Id, item.Key, item.Value.TagValue, item.Value.ImageBase64);
}
}
ValuationDetails 类:
public class ValuationDetails
{
public string TagValue { get; set; }
public string ImageBase64 { get; set; }
}
编辑改变了?对于 & 的第二个参数:
> http://localhost:0000/APIService/UploadValuationDetails?ValuationDetails={'property_details_address_address1':[{TagValue:'Test',ImageBase64:''}]}&Id=4785
将我的网址更改为高于断点的网址后,但值不正确。
编辑 2 试图在 json 结果中获取正确的值。
我想我更接近了:
http://localhost:0000/APIService/UploadValuationDetails?JsonResult={TagName:"property_details_address_address1",ValuationDetails:{TagValue:"Test","ImageBase64:""}}]&Id=4785
但现在我的 jsonResult = 0
【问题讨论】:
-
当有多个参数时,必须用
&分隔。?仅用于将路径名与第一个参数分开。 -
我正在将 Url 直接写入浏览器,以便发送有关如何创建它的屏幕截图。
-
这方面有什么进展吗?你的整流罩怎么样?
-
@paqogomez 没有,但发送给我数据的应用程序让它通过,幸运的是我能够继续前进。但是在将 json 直接放入 url 方面是行不通的。看着提琴手,它与我试图发送的格式相同,所以我不知道为什么它不起作用。可能是因为你不能设置 content type = application/json
-
@Pomster 你测试过你的json吗?因为它被顶起来了。
标签: c# json web-services url parameter-passing