gpt4 book ai didi

objective-c - RestKit 在调用时删除路径

转载 作者:行者123 更新时间:2023-12-03 16:37:37 26 4
gpt4 key购买 nike

为什么 RestKit 在进行 API 调用时删除我的路径?在通话之前它表明一切都很好。

这就是我注册的方式

AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"apiURL"]]];
[client setDefaultHeader:@"Accept" value:RKMIMETypeJSON];
[client setParameterEncoding:AFJSONParameterEncoding];
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
NSLog(@"Created client: %@", objectManager.HTTPClient);

这就是我在其他类(class)中的称呼

RKObjectManager *manager = [RKObjectManager sharedManager];
NSLog(@"HTTP Client: %@", manager.HTTPClient);

即使在我调用共享 objectManager 的其他类中,它也是正确的,但我在调用期间得到日志记录并且响应错误,因为 /api/v1 被删除。

NSLOG

2013-03-13 13:24:08.960 Project[54631:403] HTTP Client: <AFHTTPClient: 0x1033d6230, baseURL: https://my.server.com/api/v1/, defaultHeaders: {
Accept = "application/json";
"Accept-Language" = "en, ja, fr, de, es, it, pt, pt-PT, nl, sv, nb, da, fi, ru, pl, zh-Hans, zh-Hant, ko, ar, cs, hu, tr, en-us;q=0.8";
Authorization = "Bearer <My Access Token>";
"User-Agent" = "Project/1.0 (Mac OS X Version 10.7.5 (Build 11G63))";
}, registeredOperationClasses: (
), operationQueue: <NSOperationQueue: 0x1033db8c0>{name = 'NSOperationQueue 0x1033db8c0'}>
2013-03-13 13:24:08.960 Project[54631:403] Manager: <RKObjectManager: 0x1033db940>
2013-03-13 13:24:08.971 Project[54631:403] I restkit.network:RKHTTPRequestOperation.m:154 GET 'https://my.server.com/features/1234?with_lock=false'
2013-03-13 13:24:09.310 Project[54631:403] I restkit.network:RKHTTPRequestOperation.m:185 GET 'https://my.server.com/features/1234?with_lock=false' (200 OK)

最佳答案

您是否曾为RESTKIT - 实例设置过baseUrl?你做一个

[[RKObjectManager alloc] initWithHTTPClient:client]

新实例。

但是稍后你打电话

[RKObjectManager sharedManager]

首先尝试初始化共享 RKobject,例如: [RKObjectManager objectManagerWithBaseURL:...而不是使用共享实例来创建新的 AFHTTPClient 对象。

关于objective-c - RestKit 在调用时删除路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15396206/

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