Web Services 是否可以使用Fiddler的Request Builder发出JSON请求?

vlurs2pr  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(142)

我不断收到格式无效的请求。
下面是发送的原始http:

POST http://x.x.x.x/ws/MyWebService.asmx/TestEvent HTTP/1.1
contentType: "application/json; charset=utf-8",
  dataType: "json",
  data: {"strData":"1"}
Host: x.x.x.x
Content-Length: 4

任何帮助都是非常感谢的。
谢谢你!

a1o7rhls

a1o7rhls1#

我想应该是这样的:

POST /ws/MyWebService.asmx/TestEvent HTTP/1.1
Host: x.x.x.x
Content-Type: application/json; charset=utf-8
Content-Length: 15

{"strData":"1"}

并且在连接中指定要连接到的服务器。

b1payxdu

b1payxdu2#

除了Alxandr,我想强调一下"charset=utf-8"的重要性,如果你想发送一个带有一些参数的请求体,内容类型必须是这样的:

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

而要求身体应该是这样的,

{ 
  "strData":"1", 
  "strData2":"2",
  ..., 
  "strDataN":"N"
}

不需要像"data":{ ... }这样的东西

相关问题