How to change the HTTP Request Content Type for FLURL Client?

前端 未结 5 1922
小鲜肉
小鲜肉 2021-01-18 10:39

I am using flurl to submit HTTP request and this is very useful. Now I need to change the \"Content-Type\" header for some of the requests to \"appl

5条回答
  •  猫巷女王i
    2021-01-18 11:05

    The comments and another post I found (will add reference when I find it again) have pointed me to the right direction. The solution for my problem looks like:

            var jobInJson = JsonConvert.SerializeObject(job);
            var json = new StringContent(jobInJson, Encoding.UTF8);
            json.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; odata=verbose");
    
            var flurClient = GetBaseUrlForOperations("Jobs");
    
            return await flurClient.PostAsync(json).ReceiveJson();
    

    Edit: Found the related SO question: Azure encoding job via REST Fails

提交回复
热议问题