Questions tagged [nsurlrequest]

on iOS , NSURLRequest objects represent a URL load request in a manner independent of protocol and URL scheme. NSURLRequest encapsulates two basic data elements of a load request: the URL to load, and the policy to use when consulting the URL content cache made available by the implementation.

1089 questions
85
votes
7 answers

Swift GET request with parameters

I'm very new to swift, so I will probably have a lot of faults in my code but what I'm trying to achieve is send a GET request to a localhost server with paramters. More so I'm trying to achieve it given my function take two parameters…
MrSSS16
  • 853
  • 1
  • 7
  • 4
84
votes
6 answers

Append data to a POST NSURLRequest

How do you append data to an existing POST NSURLRequest? I need to add a new parameter userId=2323.
Tim
  • 947
  • 1
  • 9
  • 8
80
votes
8 answers

How to send json data in the Http request using NSURLRequest

I'm new to objective-c and I'm starting to put a great deal of effort into request/response as of recent. I have a working example that can call a url (via http GET) and parse the json returned. The working example of this is below -…
Toran Billups
  • 27,715
  • 39
  • 150
  • 262
74
votes
4 answers

ZIP file content type for HTTP request

I am sending a zip file to server via HTTPREQUEST. What should be the Content-Type HTTP header value for this kind of file? The file is a ZIP archive that contains images on type PNG. Thanks
user2960510
  • 813
  • 1
  • 6
  • 9
65
votes
7 answers

How To Check Response.statusCode in sendSynchronousRequest on Swift

How To check response.statusCode in SendSynchronousRequest in Swift The Code is Below : let urlPath: String = "URL_IS_HERE" var url: NSURL = NSURL(string: urlPath) var request: NSURLRequest = NSURLRequest(URL: url) var response:…
hossein1448
  • 825
  • 2
  • 7
  • 10
60
votes
3 answers

NSURLConnection Using iOS Swift

I am trying to follow this tutorial and connect to a JSON api using Swift and NSURLConnection. I can see that it is hitting the url but the connectionDidFinishLoading does not seem to fire. import UIKit class Remote: NSObject { var host =…
Ross Nelson
  • 809
  • 1
  • 8
  • 11
51
votes
3 answers

Add HTTP Header to NSURLRequest

Is there any way to add HTTP header to NSURLRequest object? I used to add them in NSMutableURLRequest using: [request addValue:@"PC" forHTTPHeaderField:@"machineName"]
Ahmad Kayyali
  • 8,236
  • 13
  • 47
  • 83
37
votes
5 answers

NSData and Uploading Images via POST in iOS

I have been combing through the many many posts about uploading images via POST in iOS. Despite the wealth of information on this topic, I cannot manage to correctly upload JPEG data taken from my iPhone Simulator Photo Library. The data, once on…
corescan
  • 481
  • 1
  • 5
  • 10
37
votes
2 answers

NSURLConnection/NSURLRequest gzip support

Does anyone knows if NSURLConnection/NSURLRequest have support for gzip requests. If does, can you provide more information?
mxg
  • 19,703
  • 12
  • 56
  • 77
35
votes
8 answers

SSL Error in Connection to Server through iPhone

I am trying to establish a HTTPS connection to a server using my app. But the connection fails due to following error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."…
devsri
  • 6,075
  • 5
  • 30
  • 40
35
votes
11 answers

Unsupported URL in NSURLRequest

If I run this request from my terminal I can see the JSON requests as normally: curl -XGET 192.168.0.6:8888/scripts/data/backend2/index.php/name/_all My code for the NSURlRequest is this: NSURLRequest *request = [NSURLRequest requestWithURL: …
ghostrider
  • 4,917
  • 12
  • 63
  • 113
34
votes
1 answer

Use a self-signed ssl certificate in an iphone app

I apologize in advance for the long-winded question. I'm having trouble with a self-signed SSL cert and I want to document everything I've tried so far. I'm working on an app that communicates with a REST service. The test server uses a…
Jose Ibanez
  • 3,255
  • 3
  • 25
  • 33
32
votes
1 answer

How can I get NSURLResponse body?

I'm writing an application that connect with a server using NSURLConnection. In the delegate method didreceiveresponse, if the status code is 404, I cancel the connection and I would like to show a message with a custom error that is generated in…
31
votes
3 answers

NSMutableURLRequest not obeying my timeoutInterval

I'm POST'ing a small image, so i'd like the timeout interval to be short. If the image doesn't send in a few seconds, it's probably never going to send. For some unknown reason my NSURLConnection is never failing, no matter how short I set the…
kubi
  • 44,308
  • 19
  • 90
  • 118
27
votes
7 answers

Can't set headers on my WKWebView POST request

I want to do a POST request to my WKWebView but the headers doesn't get set when I monitor the requests with Charles so the request fails. What is wrong here? NSString *post = [NSString stringWithFormat: @"email=%@&password=%@", email,…
Mattias Farnemyhr
  • 3,968
  • 3
  • 26
  • 45
1
2 3
72 73