0

解析できるように、データベースで HTTP Post Web サービスを介して CSV ファイルを取得しようとしています。私は現在このコードを持っています

-(void)viewDidLoad{
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://192.x.x.x/xyz.php?cmd=select * from record and datetime>'%@ 00:00:00' and datetime<'%@ 23:59:59' order by id limit 15", startDate, endDate]]];
    [request setHTTPMethod:@"POST"];

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(conn)
    {
        NSLog(@"Connection Successful");
    }
    else
    {
        NSLog(@"Connection could not be made");
    }}
    ////////////////////////////
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSLog(@"Did Receive Data method was called");
    NSString *contentString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    csvParser = [[CHCSVParser alloc] initWithContentsOfCSVFile:contentString];

    ParserDelegate *parserDelegate = [[ParserDelegate alloc] initParser];
    [csvParser setDelegate: parserDelegate];
    [csvParser parse];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"Error: %@", error);
}

これは、デバッグログから取得したものです

 Command string: http://192.x.x.x/xyz.php?cmd=select * from record and datetime>'2003-10-30 08:00:00 +0000 00:00:00' and datetime<'2013-10-29 07:00:00 +0000 23:59:59' order by id limit 15
[615:c07] Connection Successful
[615:c07] Error: Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x7561fd0 {NSUnderlyingError=0x71eb1c0 "bad URL", NSLocalizedDescription=bad URL}

この悪い URL を取得しています。Web ブラウザー経由で URL にアクセスできます (ブラウザーはおそらく何かを行います)。問題の内容と解決方法を知っている人はいますか?

ありがとう

4

1 に答える 1