Questions tagged [nsurlsessiondatatask]

See Apple documentation for Swift (URLSessionDataTask) and Objective C.

265 questions
0
votes
0 answers

sending multiple URLSession dataTask request synchronously and wait for the end

I would need to send multiple POST requests to my server but I'm encountering a problem of synchronization while doing it. I would need to do the following: display progress bar (download in progress...) send the first POST request for each n…
tiamat
  • 879
  • 2
  • 12
  • 35
0
votes
1 answer

NSURLSessionDataTask gives me incorrect token in a Login

I'm updating an iOS app in objective c, and i have the warning sendSynchronousRequest(_:returningResponse:) was deprecated in iOS 9.0: Use [NSURLSession dataTaskWithRequest:completionHandler:] So I changed my code…
0
votes
1 answer

iOS Swift Http request post method using header x-www-form-urlencoded?

I have to make an API call with headers as application/x-www-form-urlencoded value as a JSON string. When give parameter value and header in postman, it works fine and returns status code 200 ok. Here i am using backend node js . Post method does…
PvDev
  • 791
  • 21
  • 67
0
votes
1 answer

NSURLSession doesn't return data

I try to download a zip-archive using NSURLSessionDataTask. I am aware that there is a NSURLSessionDownloadTask, but the point is I want a didReceiveData callback (to show the progress). The code is: NSURLRequest *request = [NSURLRequest…
annaoomph
  • 552
  • 1
  • 4
  • 22
0
votes
1 answer

Ensuring method scope is not completed until URLSession data task is completed in Swift 4

I want my application to return to the original API call. Here is a sample code: func getDataFromServer() { guard let apiUrl = URL(string: endPoint) else { return } getAccessTokenValue( completionHandler:{ accesstoken in …
Kiah_Dev
  • 133
  • 1
  • 8
0
votes
1 answer

Swift 4: Making a request using URLSession and updating a global variable

I am writing an app that gets predictions for busses by making an API call. In my case, there are 5 bus routes, which I would like to loop over in order to modify each API endpoint and then make a call. I am doing this in the viewdidload method…
0
votes
1 answer

How to track URLSessionTask after Alamofire retries the request

We are using Alamofire 4 and want to match URLSessionTasks to entities in a database. We first used the taskDescription field of URLSessionTask to put UUID of a database entity there, but then figured out that Alamofire creates a new task on request…
0
votes
1 answer

NSURLSessionDataTask failed with error code -999

I am using NSUrlSession for calling backend APIs. Sometimes the APIs are working but sometimes i am getting the issues like HTTP load failed (error code: -999), HTTP load failed (error code: -1200) Refer below :- Screenshot from Xcode logs. I…
Awesome.Apple
  • 1,316
  • 1
  • 11
  • 24
0
votes
1 answer

How to use URLSession downloadTaskWithResumeData to start download again when AfterdidCompleteWithError Called..?

I have the code to download two files from Server and store It to In local using URLSession (let dataTask = defaultSession.downloadTask(with: url)). Everything Is working fine only the problem is it's downloading first file it's giving me success…
0
votes
0 answers

Getting error while fetching data from server using NSURLSession Datatask in objective c

I was trying to load data for the table using values from server.I am using NSURLSession datatask with completion handler. Whenever it reaches the nsurlsession, it shows error.This is the code which i used for getting data. - (void)geturl:(NSString…
0
votes
1 answer

Read Data/Response/Body of redirected NSURLDataTask

I am currently trying to access a webpage where the user can login using their credentials, after entering their user and password - if correct it will redirect to a new url. This new url loads a webpage with a single string which I intend to…
0
votes
3 answers

NSURLSessionDataTask completion handler not executing in command line project

I have looked on multiple stack overflow posts regarding this issue and attempted to implement those fixes to no avail. Neither of the top two answers from this question worked NSURLSessionDataTask not executing the completion handler block Here is…
Dalton Sweeney
  • 1,108
  • 3
  • 11
  • 24
0
votes
4 answers

How to print the web service request and response from dataTaskWithRequest

Can anyone guide me how to print the web service request and response from dataTaskWithRequest in json format while using swift 4.0 and objective C. Links tried: How to print NSMutableURLRequest? I can print them, but its not printing in proper…
Prajnaranjan Das
  • 1,378
  • 1
  • 9
  • 26
0
votes
2 answers

iOS swift how can I await an async task inside a function that needs a return value

I am using swift 3.0 and have created a function that returns an Array of Integers. The arrays of Integers are very specific and they are gotten from a database therefore the HTTP call is asynchronous . This is a function because I use it in 3…
Pablo prez
  • 189
  • 1
  • 5
  • 17
0
votes
1 answer

How is a proxy connection made with URLSession?

I've been looking at Apple's WWWDC 2015 Session 711: "Networking with NSURLSession". Towards the end, the speaker mentions URLSessionStreamTask, which can be used for direct socket I/O. And he mentions how a (HTTP) proxy connection can be…
CTMacUser
  • 1,996
  • 1
  • 16
  • 27