How to send XML content with HttpClient.PostAsync?

后端 未结 2 905
忘掉有多难
忘掉有多难 2021-02-04 23:43

I am trying to fulfill this rest api:

public async Task AddTimetracking(Issue issue, int spentTime)
{
    // POST /rest/issue/{issue}/timetracking/wo         


        
相关标签:
2条回答
  • 2021-02-05 00:05

    You might want to set the mediaType in StringContent like below:

    var httpContent = new StringContent(workItem.XDocument.ToString(), Encoding.UTF8, "application/xml");
    
    0 讨论(0)
  • 2021-02-05 00:24

    You could use

    var respone = await httpClient.PostAsXmlAsync(requestUri, workItem);
    

    https://msdn.microsoft.com/en-us/library/system.net.http.httpclientextensions_methods

    0 讨论(0)
提交回复
热议问题