URLSession: JSON GET & POST Requests | Swift 3, Xcode 8
Why Stack Overflow recommends it
Stack Overflow users link it as a worked example of sending JSON GET and POST requests from Swift with URLSession, especially when sending data to a web server.
Recommended by 1 people across 1 different months, 2017 to 2019.
What it is
A step-by-step Swift 3 and Xcode 8 tutorial by Kilo Loco on using URLSession to make JSON GET and POST requests in iOS apps. It explains each line of code, how to convert data bytes into readable JSON, and common bugs, without relying on third-party libraries like Alamofire.
What people said
Recommends Rangga Leo · 2019-08 · Stack Overflow · on “Why my request POST swift to php, the content always to be key in PHP”
its better and working, but i think not best solution, i had watch this video [this video] , in 28:15 minute he get some problem with me, and added Content-Type, i had do that, but in my case with my URL, i get 0 array [] in post, i dont know why `{"POST":[],"device_id":null}`
Cites Chace · 2017-09 · Stack Overflow · on “Parsing JSON array to Server with Swift 3.0”
I am trying to send a JSON array to the web server. I have looked at several examples online i.e. [this video] and Saving CoreData to a Web Server with Swift 3.0 [LINK] that have demonstrated how to parse data but I am struggling to achieve this. Below is my function which should send the data to the server: func sendRecordToServer() -> [Record] { let fetchRequest = NSFetchRequest<NSDictionary>(entityName:"Record") fetchRequest.resultType = .dictionaryResultType do { let records = try context.fetch(fetchRequest) if let jsonData = try? JSONSerialization.data(withJSONObject: records, options: []) { // jsonData is a byte sequence, to view it you would need to convert to string print(String(bytes: js
Cites udipilot · 2018-08 · Stack Overflow · on “Refreshing webpage when receiving POST JSON from swift”
Long time reader, first time asker. I have an app that sends JSON messages when a condition occurs. I'm trying to get the webpage to refresh when it receives the JSON message. I'm very new to web development and used this great tutorial to get the Get Post going: [this video] I used [LINK] great answer here to refresh the webpage when the local file "data.json" is changed. How to refresh a page whenever my json data file changes [LINK] What I can't figure out is how to trigger the refresh from swift. I'm probably missing something fundamental here but i'm not sure where to look. My swift code: @IBAction func OnPostTapped(_ sender: Any) { let parameters = ["username": "@you", "tweet": "HelloWorld"
Cites Rangga Leo · 2019-08 · Stack Overflow · on “Why my request POST swift to php, the content always to be key in PHP”
its better and working, but i think not best solution, i had watch this video [this video] , in 28:15 minute he get some problem with me, and added Content-Type, i had do that, but in my case with my URL, i get 0 array [] in post, i dont know why `{"POST":[],"device_id":null}`