Questions tagged [urlrequest]
226 questions
2
votes
0 answers
URLRequest.addValue() causes SwiftUI calendar to revert date
The function below is called every 3 seconds and looks like:
func fetchItems(){
let url = URL(string: itemUrl)!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.addValue("Item \(self.item)", forHTTPHeaderField:…
![](../../users/profiles/12771165.webp)
nickcoding
- 31
- 3
- 13
2
votes
1 answer
Pattern cannot match values of type 'URLRequest'
I am trying to upload an image in Alamofire parameters. But I keep getting this error that wont let me compile. I am using swift 5.
Error
let image = profilePictureView.image!
let imageData =…
![](../../users/profiles/13712922.webp)
Sarmad
- 21
- 2
2
votes
1 answer
wget.download() only works for some links
I have a list of some links (which are pdf files). I'm running wget.download() for each link in the list. However, only some of them get downloaded and then I get:
File "/home/.local/lib/python3.6/site-packages/wget.py", line 526, in download
…
![](../../users/profiles/13067694.webp)
Jbd
- 295
- 1
- 10
2
votes
1 answer
JSON Decoder fails with URLSession
Pretty new to Swift and trying to learn SwiftUI this week. Attempting a GET request from a Joke API and eventually looking to get it to refresh every time you press a button.
I have a feeling I'm defining my structs incorrectly or maybe not decoding…
![](../../users/profiles/13730648.webp)
Josh Trommel
- 29
- 2
2
votes
1 answer
Swift - Convert URLRequest to cURL
How to convert URL Request to cURL?
I know there are plugins available in Alamofire / Moya.
But I'm using native code.
Here is how I'm generating URLRequest.
var urlRequest = URLRequest(url: url) // URL is a param herel
var newHeaders: [String:…
![](../../users/profiles/140765.webp)
Sagar R. Kothari
- 23,587
- 48
- 158
- 226
2
votes
4 answers
JSON request from swift showing empty array in php
I am trying to make a request to a PHP server from my swift app. For some reason php is showing an empty array as the $_REQUEST variable. I have looked through stack overflow and implemented everything I can find that might help, but still getting…
![](../../users/profiles/3380456.webp)
Neglected Sanity
- 1,194
- 1
- 17
- 36
2
votes
1 answer
URLRequest fails before timeout
I want to set different timeouts for different requests. My request routine looks like:
var request = URLRequest(url: url,
cachePolicy: .reloadIgnoringLocalCacheData,
timeoutInterval: timeout)
//…
![](../../users/profiles/1388851.webp)
Valentin Shamardin
- 3,371
- 3
- 30
- 43
2
votes
3 answers
URLSession sends GET request instead of POST
That's how I'm doing a POST request
var request = URLRequest(url: url)
let methodString = mehtod.rawValue
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json",…
![](../../users/profiles/1090590.webp)
BergP
- 3,315
- 3
- 31
- 55
2
votes
1 answer
Convert CURL to URLRequest
I’m trying to converting the the following curl request Swagger gives me to URLRequest:
curl -X GET --header 'Accept: application/json'
--header 'Authorization: key ttn-account-v2.'
…
![](../../users/profiles/6082017.webp)
ChrisTheGreat
- 382
- 3
- 16
2
votes
0 answers
Swift 4: Multiple network request on Linux
I'm trying to make a network request multiple times and I'm facing with error core dumped error on linux (macOS its ok).
Either request1() or request2() are aborted
import Foundation
import Dispatch
func request2() {
for i in 1...5 {
…
![](../../users/profiles/846780.webp)
Klevison
- 3,072
- 1
- 16
- 28
2
votes
1 answer
Authorization Header in Swift POST
My app creates POST request with Authorization header - it looks like :
let accessToken = "veryCoolToken"
var request = URLRequest(url: myURL)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField:…
![](../../users/profiles/1218405.webp)
moonvader
- 13,845
- 14
- 51
- 93
2
votes
0 answers
How to HTTP-CONNECT with an URLRequest in Swift
I want to establish a TCP tunnel through an HTTP(S) proxy with high level APIs, i.e. URLRequest provided by iOS/macOS SDKs in Swift with the HTTP CONNECT command. I have the following code, assuming the proxy runs on localhost:8080:
import…
![](../../users/profiles/5082444.webp)
Max
- 1,171
- 14
- 26
2
votes
0 answers
I'm trying to send a POST request with Alamofire 4.0 & Swift 3, but the server receive GET parameters
I'm trying to make a request sending parameters by POST, Alamofire request says that its POST, but my server get the parameters by GET.
let formParams:[String : String] = ["facebook_id": COUtils.userProfile["id"]!, "full_name": name, "email":…
![](../../users/profiles/3898548.webp)
Patricio Bravo
- 396
- 5
- 8
2
votes
1 answer
Upload a picture to cloudinary using the REST API
We are developing an App using AIR/AS3 and would like to upload a picture to cloudinary via the REST API from the client, instead of using Node.js.
Reading the Documentation of cloudinary, we have found that it should be done via a HTTP/S POST…
![](../../users/profiles/1489345.webp)
GV3
- 491
- 3
- 16
2
votes
3 answers
AS3 won't send POST data to browser - wrong URLRequestHeader content type?
I have the following code in my AS3 Flash code that takes a screenshot within the swf using JPGEncoder and sends it to the url where i write it to a file in PHP.
I did run into the Google Chrome Pepperflash issue recently where the function just…
![](../../users/profiles/2091861.webp)
odd_duck
- 3,461
- 6
- 36
- 74