如何发送带有json正文的POST请求? (RestSharp C#)

时间:2020-10-28 19:29:16

标签: c# json http post restsharp

我在post方法中使用参数,例如:

https://localhost:44345/exemple?id=123&value=123&anotherValue=123

但是,我不想在标题中显示参数,如何将它们作为json发送到正文中,例如:

{
    "id": "123",
    "value": "123",
    "anotherValue": "123"
}

让我知道是否有人已经问过了,谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用AddJsonBody方法。 RestSharp官方文档中有一个示例:https://restsharp.dev/usage/parameters.html#addjsonbody

使用(第三方)库时,一般建议是查阅文档。