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.
Questions tagged [nsurlrequest]
1095 questions
113
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
- 1,133
- 2
- 8
- 4
105
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
- 1,123
- 2
- 8
- 9
85
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
- 957
- 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,111
- 40
- 155
- 268
79
votes
9 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
- 975
- 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
- 829
- 1
- 8
- 13
52
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,233
- 13
- 49
- 83
38
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
- 5,131
- 14
- 72
- 120
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
- 477
- 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
- 20,946
- 12
- 59
- 80
36
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,173
- 5
- 32
- 40
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,325
- 3
- 28
- 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…

telemaco
- 321
- 1
- 3
- 4
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
- 48,104
- 19
- 94
- 118
29
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
- 4,148
- 3
- 28
- 49