Skip to content

"无法发送具有此谓词类型的内容正文。 #1

@sitsh

Description

@sitsh

vs 2017 15.7.2
framework 4.6.1

restapi 接口 地址

https://report.im.jpush.cn/v2/messages?count=500&begin_time=2015-11-02 10:10:10&end_time=2015-11-02 10:10:12

public async Task<HttpResponse> GetMessageHistoryAsync(int count, string beginTime, string endTime)

var request = new HttpRequestMessage(HttpMethod.Get, url)
            {
                Content =  new StringContent(string.Empty, Encoding.UTF8, "application/json")
                
            };

            HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(request).ConfigureAwait(false);
            string content = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
            return new HttpResponse(httpResponseMessage.StatusCode, httpResponseMessage.Headers, content);

网上查了好像是因为 httpclient get 方法 不能发送 Content 有值的数据
如果注释

//Content = new StringContent(string.Empty, Encoding.UTF8, "application/json")

这行代码 又因为 Content 没有设置 application/json 返回 404 结果

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions