我如何使用 Rest Sharp API put 方法
how can i use Rest Sharp API put method
嘿,我正在尝试像下面的代码一样使用 put 方法。我需要这样的身材
{
"lines": [
{
"lineId": 300198921,
"quantity": 1
}],
"params": {
},
"status": "Picking"
}
i 运行 talend 上的请求 API 没有问题,但在 c# 中总是出错
public static void TrendyolDurumGüncelle()
{
client = new RestClient("https://api.trendyol.com/sapigw/suppliers/{supplierId}/shipment-packages/{Id}");
client.Authenticator = new HttpBasicAuthenticator(TrendyolUserName, TrendyolPassword);
request = new RestRequest("https://api.trendyol.com/sapigw/suppliers/{supplierId}/shipment-packages/{Id}", Method.PUT);
request.AddUrlSegment("supplierId", TrendyolMerchantId);
request.AddUrlSegment("Id", "173657633");
var body = new { lines = new {lineId = "300198921", quantity = 3 } , @params = new { } ,status = "Picking" };
request.AddJsonBody(body);
var response = client.Execute(request);
var content = response.Content;
}
在你的示例中 json lines
属性 是数组,所以尝试:
var body = new
{
lines = new[] { new { lineId = "300198921", quantity = 3 } } ,
@params = new { } ,
status = "Picking"
};
嘿,我正在尝试像下面的代码一样使用 put 方法。我需要这样的身材
{
"lines": [
{
"lineId": 300198921,
"quantity": 1
}],
"params": {
},
"status": "Picking"
}
i 运行 talend 上的请求 API 没有问题,但在 c# 中总是出错
public static void TrendyolDurumGüncelle()
{
client = new RestClient("https://api.trendyol.com/sapigw/suppliers/{supplierId}/shipment-packages/{Id}");
client.Authenticator = new HttpBasicAuthenticator(TrendyolUserName, TrendyolPassword);
request = new RestRequest("https://api.trendyol.com/sapigw/suppliers/{supplierId}/shipment-packages/{Id}", Method.PUT);
request.AddUrlSegment("supplierId", TrendyolMerchantId);
request.AddUrlSegment("Id", "173657633");
var body = new { lines = new {lineId = "300198921", quantity = 3 } , @params = new { } ,status = "Picking" };
request.AddJsonBody(body);
var response = client.Execute(request);
var content = response.Content;
}
在你的示例中 json lines
属性 是数组,所以尝试:
var body = new
{
lines = new[] { new { lineId = "300198921", quantity = 3 } } ,
@params = new { } ,
status = "Picking"
};