I am trying to create a file from a text string in a web server in a folder C:\inetpub\wwwroot\AlekaConsulting\AlekaConsulting\License using IIS 10.0.14393.0 on a Windows Server 2016 environment using the following Objective-C code on macOS Catalina, but no file is created and the returnString variable contains the error message
The same error appears if I use PUT rather than POST as HTTPmethod.
No verbs are listed in the Request Filtering tab of IIS Manager, which means no verbs are blocked. webDav is not installed as a server feature.
Content can be successfully read from files in the specified folder.
Is the error connected with the URL being accessed via https?
fg
Code Block 405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
The same error appears if I use PUT rather than POST as HTTPmethod.
No verbs are listed in the Request Filtering tab of IIS Manager, which means no verbs are blocked. webDav is not installed as a server feature.
Content can be successfully read from files in the specified folder.
Is the error connected with the URL being accessed via https?
Code Block -(void) UploadFileContent: (NSString *) fileContent{ NSString *urlString = @"https://captionpro.com.au:444/AlekaConsulting/License"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSMutableData *body = [NSMutableData data]; NSString *boundary = @"---------------------------14737809831466499882746641449"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"parameter1\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:fileContent] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"%@", returnString); }
fg