安装的版本
NuGet\Install-Package RestSharp -Version 106.15.0
加入 token
var clientForSave = new RestClient("http://10.30.35.22:32080/ipms/v1/12/bulletin-board/reportwork/save");
var requestForSave = new RestRequest(Method.POST);
var dataToSave = new
{
id = "7481ee09-3583-4ffc-94cb-2241279efa6b",
text = "机加工1210上线10%",
zbgrq = "2024-08-20",
time = 0,
zweek = "202434",
externalId = "SPG-2024-051",
process = 30,
type = "T"
};
requestForSave.AddJsonBody(JsonConvert.SerializeObject(dataToSave));
requestForSave.AddHeader("Authorization", $"Bearer 9ecc1441-c61c-413a-8c95-a989e4ebbe27");
var responseForSave = clientForSave.Execute(requestForSave);
if (responseForSave.IsSuccessful)
{
Console.WriteLine("Data saved successfully.");
}
else
{
Console.WriteLine($"Request for save failed with status code: {responseForSave.StatusCode}");
}