json PUT 请求
你好,我使用 JSONKit。我需要通过 json 请求向服务器发送状态更新来更新 linkedin 站点中的状态。这是我发送的代码。我的价格是 400 欧元。请告诉我有什么错误。
谢谢。
NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"linkedin-html",@"contentType",@"My Fancy Update",@"body",nil];
NSString *str =[jsonDict JSONString];
NSMutableData *requestData = [NSMutableData dataWithBytes:[str UTF8String] length:[str length]];
[self setHTTPBody:requestData];
[self setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[self setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
Hi iam usng JSONKit. i need to update status in linkedin site by sending the status update through json request to server. this is the code im sendin. im gettin 400 eroor. please tel me whats the mistake.
thanks.
NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"linkedin-html",@"contentType",@"My Fancy Update",@"body",nil];
NSString *str =[jsonDict JSONString];
NSMutableData *requestData = [NSMutableData dataWithBytes:[str UTF8String] length:[str length]];
[self setHTTPBody:requestData];
[self setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[self setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不知道这是否完全适合您的使用需求,我正在使用 iPhone 并连接到 jayrock .net Web 服务。
这是我用来处理所有呼叫的命令。
另外,我正在使用 json-framework
dont know if this will fit your usage needs exactly, I am using iphone and connecting to jayrock .net webservices.
Here is the command I use to handle all my calls.
Also, I am using the json-framework
我首先将您的 json 有效负载和连接响应数据写入一个简单的文本文件并进行审查(或发布,如果您希望我们看一下)。我发现这是我在将数据发布到服务时发现问题的最简单方法。你正在使用一个库,所以我的猜测是有效负载应该没问题,但你永远不知道。尽管我不能说我曾经使用过 LinkedIn 的 api,但响应数据可能包含更多关于真实问题的提示。
另外,我没有看到您在哪里指定该请求是“PUT”。您是否包含
使用此代码将有效负载写入文件系统(抱歉格式,它在移动 safari 中不能很好地播放):
I would start by writing your json payload and the connection response data to a simple text file and review (or post, if you want us to take a look). I've found that's the easiest way for me to spot issues when posting data to services. You're using a library, so my guess is the payload should be fine, but you never know. The response data may include more hints to the true issue, although I can't say I've ever used LinkedIn's api.
Also, I didn't see where you specified that the request was a "PUT". Did you include
Use this code to write the payload to the file system (sorry for the formatting, it's not playing nicely with mobile safari):
也许这个可以帮助你。
May be this can help you.