objective c - overwrite JSON data on server -


my app pulling down json file server (godaddy) , parsing array. user able add new record existing json. i'm running issues when try post of data server.

to clear, i'm trying overwrite existing file that's on server new data. know ftp isn't direction need going, i'm not using database of kind. files on server.

i've made sure json valid , i've called godaddy make sure don't need change permissions. i've used directory ftp before.

could remote_path_to_root_app_folder uses ftp credentials? if so, url need use?

- (void)postexamplesdictionarytoserver:(nonnull nsstring *)dname                                        :(nonnull nsstring *)rname                                        :(nonnull nsdata *)jsondata {     nsstring *userfileurlstring = [nsstring stringwithformat:@"%@/%@/%@tester.json", remote_path_to_root_app_folder, dname, rname];     nsurl    *userfileurl       = [nsurl urlwithstring:userfileurlstring];      nsstring *postlength        = [nsstring stringwithformat:@"%lu", (unsigned long)[jsondata length]];      nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init];     [request seturl:userfileurl];     [request sethttpmethod:@"post"];     [request setvalue:postlength forhttpheaderfield:@"content-length"];     [request setvalue:@"application/json; charset=utf-8" forhttpheaderfield:@"content-type"];     [request sethttpbody:jsondata];      [[self.session uploadtaskwithrequest:request fromdata:jsondata completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error)     {         nsstring *requestreply = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding];         nslog(@"error: %@", error);     }] resume]; } 

edit: logged nserror passed completion handler , got this:

error: (null) 

but...if change url file doesn't exist on server, this:

error: error domain=nsurlerrordomain code=-1008 "resource unavailable"      userinfo={nsunderlyingerror=0x7fca8ad44280 {error domain=kcferrordomaincfnetwork code=-1008 "(null)"},      nserrorfailingurlstringkey=ftp://*****:*****@ftp.*****.com/public_html/app/******/file.json,      nserrorfailingurlstringkey=ftp://*****:*****@ftp.*****.com/public_html/app/******/file.json, nslocalizeddescription=resource unavailable} 

does mean it's not attempting upload task, request somehow?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -