Restsharp 将 guid 添加到 body,如何删除它?
Restsharp adds guid to body, how do I remove it?
我的代码如下,很简单。我试图匹配一个邮递员呼叫并且它非常接近,但是当我在邮递员中进行呼叫时它看起来不同,特别是 restsharp 在我在提琴手中看到的 body 周围添加了一个 guid。向导似乎打断了我的通话,我该如何删除它?
string url = "https://url/api/";
var client = new RestClient(url);
client.AddDefaultHeader("x-ads-dev", "Key");
var request = new RestRequest("telemetry", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", datapoint, ParameterType.RequestBody);
var response = await client.PostAsync(request);
这是 Fiddler 显示的内容:
POST http://url/api/telemetry HTTP/1.1
Host: api.adsprism.com
x-ads-dev: key
Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml
User-Agent: RestSharp/107.3.0.0
Accept-Encoding: gzip, deflate, br
Content-Type: application/json; boundary="717cb9fd-684d-424e-bd0a-cf6b0bb11bac"
Content-Length: 398
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/json"
[{"entityID":2123,"locationID":33,"data":[{"dateTime":"2020-08-03 23:05:00","reading":0,"flags":0,"quality":15,"ignore":false},{"dateTime":"2020-09-27 03:10:00","reading":0,"flags":0,"quality":15,"ignore":false}]}]
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac--
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac-- guid 不在 fiddler postman 请求中,它似乎导致了来自 restsharp 的错误请求错误。那么如何让 restsharp 不生成它呢?
编辑:添加了 postman fiddler 以显示差异。
POST http://api.url/api/telemetry HTTP/1.1
x-ads-dev: key
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Postman-Token: 5f186e6d-cad0-482c-b7b8-a50559f24b87
Host: api.adsprism.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 513
[
{
"entityID": 2123,
"locationID": 33,
"data": [
{
"dateTime": "2020-08-03 23:05:00",
"reading": 0,
"flags": 0,
"quality": 0,
"ignore": true
},
{
"dateTime": "2020-09-27 03:10:00",
"reading": 0,
"flags": 0,
"quality": 0,
"ignore": true
}
]
}
]
阅读 docs 会有帮助。
const string url = "https://url/api/";
var client = new RestClient(url);
client.AddDefaultHeader("x-ads-dev", "Key");
var request = new RestRequest("telemetry", Method.Post);
request.AddStringBody(datapoint, DataType.Json);
var response = await client.PostAsync(request);
我的代码如下,很简单。我试图匹配一个邮递员呼叫并且它非常接近,但是当我在邮递员中进行呼叫时它看起来不同,特别是 restsharp 在我在提琴手中看到的 body 周围添加了一个 guid。向导似乎打断了我的通话,我该如何删除它?
string url = "https://url/api/";
var client = new RestClient(url);
client.AddDefaultHeader("x-ads-dev", "Key");
var request = new RestRequest("telemetry", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", datapoint, ParameterType.RequestBody);
var response = await client.PostAsync(request);
这是 Fiddler 显示的内容:
POST http://url/api/telemetry HTTP/1.1
Host: api.adsprism.com
x-ads-dev: key
Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml
User-Agent: RestSharp/107.3.0.0
Accept-Encoding: gzip, deflate, br
Content-Type: application/json; boundary="717cb9fd-684d-424e-bd0a-cf6b0bb11bac"
Content-Length: 398
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="application/json"
[{"entityID":2123,"locationID":33,"data":[{"dateTime":"2020-08-03 23:05:00","reading":0,"flags":0,"quality":15,"ignore":false},{"dateTime":"2020-09-27 03:10:00","reading":0,"flags":0,"quality":15,"ignore":false}]}]
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac--
--717cb9fd-684d-424e-bd0a-cf6b0bb11bac-- guid 不在 fiddler postman 请求中,它似乎导致了来自 restsharp 的错误请求错误。那么如何让 restsharp 不生成它呢?
编辑:添加了 postman fiddler 以显示差异。
POST http://api.url/api/telemetry HTTP/1.1
x-ads-dev: key
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Postman-Token: 5f186e6d-cad0-482c-b7b8-a50559f24b87
Host: api.adsprism.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 513
[
{
"entityID": 2123,
"locationID": 33,
"data": [
{
"dateTime": "2020-08-03 23:05:00",
"reading": 0,
"flags": 0,
"quality": 0,
"ignore": true
},
{
"dateTime": "2020-09-27 03:10:00",
"reading": 0,
"flags": 0,
"quality": 0,
"ignore": true
}
]
}
]
阅读 docs 会有帮助。
const string url = "https://url/api/";
var client = new RestClient(url);
client.AddDefaultHeader("x-ads-dev", "Key");
var request = new RestRequest("telemetry", Method.Post);
request.AddStringBody(datapoint, DataType.Json);
var response = await client.PostAsync(request);