我遇到了一个问题,我的目标是通过API发送修改请求,所以我正在使用HttpClient
进行request
。
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
public class patchticket
{
public string patch(string ticketid)
{
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("PATCH"), "https://desk.zoho.com/api/v1/tickets/"+ticketid))
{
request.Headers.TryAddWithoutValidation("Authorization", "6af7d2d213a3ba5e9bc64b80e02b000");
request.Headers.TryAddWithoutValidation("OrgId", "671437200");
request.Content = new StringContent("{\"priority\" : \"High\"}", Encoding.UTF8, "application/x-www-form-urlencoded");
var response = httpClient.SendAsync(request);
return response
}
}
}
}
结果是我没有任何错误,但是更改没有生效。
认证凭据没问题,我已经使用相同的参数通过curl测试过,它很好地工作了。