发出一个http post请求以在Blackberry OS中发送一个json文件< 7.X

时间:2013-04-19 10:20:23

标签: json post blackberry httprequest

我想从我的BB设备向我的本地服务器发送一个JSON文件。在iOS上,我使用了ASIHttpRequest库,我所做的是:

//send json file , using ASIHttpClass
NSURL *url = [NSURL URLWithString:urlStr];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
request.timeOutSeconds = TIME_OUT_SECONDS;
[request setRequestMethod:@"PUT"];

NSString *credentials= [self encodeCredentials];
[request addRequestHeader:@"Authorization" value:[[NSString alloc] initWithFormat:@"Basic %@",credentials]];
[request addRequestHeader:@"Content-Type" value:@"application/json; charset=utf-8"];        

[request appendPostData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
[request startSynchronous];

if([request responseStatusCode]==200){
   return true;
} else {
     return false;
    }

我如何在BlackBerry OS中实现相同的功能< 7.X申请?

0 个答案:

没有答案