0

i have use this code but i don't know why we use POST and why we use GET in rest API?

-(IBAction)ClickSignUP:(id)sender
     {
        NSString *urlLoc = @"YOUR URL";


        NSLog(@"%@",urlLoc);

        NSString * requestString = [NSString stringWithFormat:@"Name=%@&Email=%@&Password=%@&MobileNumber=%@&BloodGroup=%@&DeviceID=%@&City=%@&DeviceType=I",txtName.text,txtEmail.text,txtPassword.text,txtMobileno.text,strBlood,strDeviceID,txtCity.text];

            NSData *postData = [requestString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
            NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
            request = [[NSMutableURLRequest alloc] init];
            [request setURL:[NSURL URLWithString:urlLoc]];
            [request setHTTPMethod:@"POST"];
            [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
            [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            [request setHTTPBody:postData];
            PostConnectionSignUp = [[NSURLConnection alloc] initWithRequest:request delegate:self];

        }

how we can integrate kingfisher image loading in swift 3.0

pod 'Kingfisher', '~> 4.6.1.0'
  import Kingfisher    
imgVUser.kf.setImage(with: URL(string: data.propertyImage), placeholder: UIImage.init(named: "placeholder"), options: [.transition(.fade(1))], progressBlock: nil, completionHandler: nil)

how we can integrate KRProgress Indicator in swift 3.0

pod 'KRProgressHUD', '~> 3.1.1.0'

DispatchQueue.main.async {          
                KRProgressHUD.show()    
            }

DispatchQueue.main.async {
                KRProgressHUD.dismiss()
            }
princ___y
  • 1,009
  • 1
  • 9
  • 25
  • Read the RFC for HTTP 1.1 to learn the difference between GET and POST. After that, ask the API provider why they chose GET or POST for any particular endpoint. – Avi Jun 02 '16 at 04:44
  • Oh, and after that, read some good books on code design to learn why making a request from an event handler is bad design. – Avi Jun 02 '16 at 04:45
  • could you provide some link? to read this? – princ___y Jun 02 '16 at 04:46
  • Duplicate question almost. Whatever, check these: 1)http://stackoverflow.com/questions/17854340/difference-between-post-get-method-in-json-parsing-in-ios 2) http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get 3) http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get – Jamshed Alam Nov 08 '16 at 07:12
  • pod 'Kingfisher', '~> 4.6.1.0' import Kingfisher imgVUser.kf.setImage(with: URL(string: data.propertyImage), placeholder: UIImage.init(named: "placeholder"), options: [.transition(.fade(1))], progressBlock: nil, completionHandler: nil) – princ___y May 12 '18 at 07:52

4 Answers4

4

Main difference between GET and POST

GET - When you get some data from URL Like name, address, gender etc. GET methods is only use for retrive data from URL.

Post - When you send some data on server then use post methods.

yankit Patel
  • 308
  • 1
  • 11
2

GET : The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.

The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring data already held by the client.

POST : The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:

  - Annotation of existing resources;
  - Posting a message to a bulletin board, newsgroup, mailing list,
    or similar group of articles;
  - Providing a block of data, such as the result of submitting a
    form, to a data-handling process;
  - Extending a database through an append operation.

The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a database.

Read this LINK for more information

Community
  • 1
  • 1
0

your code is using post method.

i.e.

Post Method:
urlLoc = this is url before. //i.e www.google.com
requestString = you are add your textfield value after urlLoc. //name='Bhadresh'
- this method user doesn't see requestString data in browser url

Get Method:
urlLoc + requstString = website.com/directory/index.php?name=YourName&bday=YourBday
- this method user see requestString data in browser url

More infomation:: What is the difference between POST and GET?

Community
  • 1
  • 1
Bhadresh Kathiriya
  • 2,565
  • 2
  • 17
  • 35
0

Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data from client to server in http protocol.

Soni Kumar
  • 247
  • 1
  • 3
  • 13