gpt4 book ai didi

restkit - json 响应被解释为 text/plain

转载 作者:行者123 更新时间:2023-12-04 01:42:47 25 4
gpt4 key购买 nike

我有以下代码:

NSURL *URL = [NSURL URLWithString:[@"some-address"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];

RKObjectRequestOperation *requestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:[self.objectManager responseDescriptors]];

[requestOperation start];
[requestOperation waitUntilFinished];

我收到以下错误。
Object request failed: Underlying HTTP request operation failed with error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
    "application/x-www-form-urlencoded",
    "application/json"
)}, got text/plain" UserInfo=0x1f5e3c40 {NSLocalizedRecoverySuggestion={"total_rows":16,"offset":1,"rows":[

{"id":"1","key":1,"value":{"_id":"1","_rev":"1-e75042683867a7030fc4d3aa3b72ef35",
"user":{
"userId":"1",
"name":"A",
.......
]}}, .....

当响应为 Json 格式时,为什么会出现此错误?

最佳答案

我们做到了。刚刚设置

[RKMIMETypeSerialization registerClass:[RKXMLReaderSerialization class] forMIMEType:@"text/plain"];

如果您使用的是 JSON 而不是 XML(XML 就是我们的案例),请随意使用 RKNSJSONSerialization 类更改 RKXMLReaderSerialization 类。

关于restkit - json 响应被解释为 text/plain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14383659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com