辞書に追加する位置データがあります
[latLong setObject:@"33.6667" forKey:@"lat"];
[latLong setObject:@"73.1667" forKey:@"lng"];
[locDict setObject:latLong forKey:@"location"];
[locDict setObject:@"50" forKey:@"accuracy"];
[locDict setObject:@"Conve" forKey:@"name"];
[locDict setObject:[NSArray arrayWithObjects:@"moving_company", @"general_contractor", nil] forKey:@"types"];
[locDict setObject:@"en" forKey:@"language"];
次に、投稿リクエストからJSONデータを作成します
NSString *jsonRequest = [locDict JSONRepresentation];
NSData *requestData= [jsonRequest dataUsingEncoding:NSUTF8StringEncoding];
NSString *urlString = @"https://maps.googleapis.com/maps/api/place/add/json&sensor=false&key=AIzaSyDrGuhso6MRdEmnvAMa-e4iMQuYo"; //key altered
NSString *encodedUrl = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:encodedUrl]];
[req setHTTPMethod:@"POST"];
[req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[req setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[req setHTTPBody:requestData];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:req delegate:self];
常に404エラーが発生します。デバイスからlat-lngを使用し、センサーパラメーターをtrueに設定してみましたが、結果は常に同じです。