fiddler中的POST请求:发送具有另一个对象作为成员的自定义对象



我需要使用json请求用fiddler测试一个端点。我知道你可以通过将这个添加到请求主体来发送自定义对象。。。。

{
    "Name" : "testing//moretest//tiredd",
    "Description": "this is a test.",
}

但这个对象有一个自定义的"元数据"对象,我也想填充它。。。

public class MetadataModel
{
    public int Identifier { get; set; }
    public string Path { get; set; }
}

很明显,我试着将请求正文如下,但没有成功。。。有什么帮助吗?

{
    "Name" : "testing//moretest//tiredd",
    "Description": "this is a test.",
    "Metadata" : {"Identifier" : "2", "Path" : "Test"}
}

我还试着用引号把大括号括起来。。。没有运气。

如果省略"Metadata"行,则填充对象,Metadata对象为null。当我包含它时,整个对象都是空的

{
"Name" : "testing//moretest//tiredd",
"Description": "this is a test.",
"Metadata" : {"Identifier" : 2, "Path" : "Test"}
}

假设Ralph WIllgoss的答案不能解决问题(可能,我以前错过了(,你可能只需要从你的2-JSON整数中删除引号就可以了。JSON整数不应该被引号引用,所以它不会正确地处理这个问题。

是否正确设置了json的请求头

Content-Type: application/json; charset=utf-8

你在HTTP响应中得到了什么,你能发布吗

相关内容

最新更新