[ckan-dev] Subject: Re: problem inserting a row in the dataset
Dominik Moritz
dominik.moritz at okfn.org
Mon Jun 3 15:02:14 UTC 2013
Hi fran,
I don't know anything about iOS programming but I will try my best ;-)
Can you try to change:
``NSString *urlString = @"http://sandboxdw.pediacities.com";``
to:
``NSString *urlString =
@"http://sandboxdw.pediacities.com/api/3/datastore_upsert";``
and:
```
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";
```
to:
```
NSString* str =
@"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";
```
If this does not help and you are still getting errors from CKAN,
let's try to change the `str` to a json string:
```
NSString* str = @"{\"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\"}";
```
If that doesn't help, we could have a skype call and see whether we
can get this working when without the delays over email. My skype name
is d.moritz.
Best wishes,
Dominik
Dominik Moritz
CKAN developer | skype: d.moritz | @doobly_doo
The Open Knowledge Foundation
Empowering through Open Knowledge
http://okfn.org/ | @okfn | http://ckan.org | @CKANproject
On 3 June 2013 16:34, <fwolanczyk at cs.com> wrote:
> 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];
> }
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
More information about the ckan-dev
mailing list