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

前端 未结 5 1902
小鲜肉
小鲜肉 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条回答
  •  耶瑟儿~
    2021-01-18 11:13

    I'm not an OData expert and I don't know what API you're calling (SharePoint?), but based on most examples I've seen, what you typically want to do is ask the server to send verbose OData in the response, rather than declare that you're sending it in the request. In other words, you want to set the ;odata=verbose bit on the Accept header, not Content-Type. application/json should be good enough for Content-Type, and Flurl will set that for you automatically, so just try this change and see if it works:

    .WithHeader("Accept", "application/json;odata=verbose");
    

提交回复
热议问题