[ckan-dev] Subject: Re: problem inserting a row in the dataset

fwolanczyk at cs.com fwolanczyk at cs.com
Mon Jun 3 14:34:32 UTC 2013


hi there,
i did read the wc3 thing on get/post  - i have enclosed my ios method that makes the request - it gets a "200" response, doesnt insert a row, and oldly enough returns in 



- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [self.datalistMetaData appendData:data];   
    // NSLog (@"data is %@", data);
   //  NSLog (@"datalistMetaData is %@", datalistMetaData);
}


 the "entire" html page in hex characters from sandboxdw.pediacities.com which seems weird...



heres the connection method, the query string works fine - but this DOES NOT insert a row 



- (void)postUpdateToDataset{
    // try this against database to update...
    self.datalistMetaData = [NSMutableData data];
    NSString *urlString = @"http://sandboxdw.pediacities.com";
  /*
    NSString* str = @"/api/3/action/datastore_upsert?resource_id=16d8ab0b-38bd-41b4-9b0c-49ff0420d4f1&records=[{\"Division\":\"BMTFake\",\"Line\":\"BroadwayFake\",\"Station_Name\":\"49th St\",\"Station_Latitude\":\"40.760621\",\"Station_Longitude\":\"-73.984139\"}]&method=insert";
   */
    
            NSString* str = @"/api/3/action/datastore_upsert?resource_id=16d8ab0b-38bd-41b4-9b0c-49ff0420d4f1&records=[{\"Division\": \"BMTFake\",\"Line\":\"AstoriaFake\",\"Station_Name\":\"Ditmars Blvd\",\"Station_Latitude\":\"40.775149\",\"Station_Longitude\": \"73.912074\",\"Route_1\":\"A\",\"Route_2\":\"B\",\"Route_3\":\"B\",\"Route_4\":\"B\",\"Route_5\":\"B\",\"Route_6\":\"B\",\"Route_7\": \"B\",\"Route_8\": \"B\",\"Route_9\":\"B\",\"Route_10\":\"B\",\"Route_11\":\"B\",\"Entrance_Type\":\"staff\",\"Entry\":\"yes\",\"Exit_Only\":\"nope\",\"Vending\":\"yep\",\"Staffing\":\"always\",\"Staff_Hours\":\"daily\",\"ADA\":\"yes\",\"ADA_Notes\":\"door\",\"Free_Crossover\":\"no\",\"North_South_Street\":\"3street\",\"East_West_Street\":\"4street\",\"Corner\":\"nw\",\"Latitude\":\"40.775149\",\"Longitude\":\"-73.912074\"}&method=insert";
 
    /*
     NSString* str = @"/api/3/action/datastore_search?resource_id=16d8ab0b-38bd-41b4-9b0c-49ff0420d4f1&limit=5";
     */
            
    NSData *theData = [str dataUsingEncoding:NSUTF8StringEncoding]; 
    
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];    
    
    NSMutableData *body = [NSMutableData data];


 // Content-Type: application/x-www-form-urlencoded
//application/octet-stream  try binary/octet stream
    [body appendData:[@"Content-Type: binary/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];   
    
    [body appendData:[NSData dataWithData:theData]];


    [request setHTTPBody:body];
    
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    [connection start];


    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    
    parseQueue = [NSOperationQueue new];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(addOutages:)
                                                 name:kAddOutagesNotif
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(outagesError:)
                                                 name:kOutagesErrorNotif
                                               object:nil];
}



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130603/953b6e83/attachment-0001.html>


More information about the ckan-dev mailing list