Questions tagged [urlcomponents]

A Swift Foundation structure that parses URLs into and constructs URLs from their constituent parts.

URLComponents is a Swift Foundation structure that parses URLs into and constructs URLs from their constituent parts. Specifically, it allows you to add queries and other components to a URL, and URLComponents And URLQueryItem will perform the necessary percent-encoding as contemplated in RFC3986.

See also

12 questions
4
votes
0 answers

How can I add http or https to a swift URL?

I have a swift app and I'm trying to use rich links. I first detect a link in some dynamic text using the following: do { let detector = try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) let matches =…
alionthego
  • 8,508
  • 9
  • 52
  • 125
2
votes
1 answer

How to fix URLQueryItem in swift

I need to pass an query param to my URLComponents: URLQueryItem(name: "scope", value: "channel%3Amanage%3Apolls+channel%3Aread%3Apolls") but when i see the url in debug i see this : scope=channel%253Amanage%253Apolls+channel%253Aread%253Apolls The…
alexmasu
  • 23
  • 2
1
vote
0 answers

Using swift URLComponents to extract param value from url

I've tried the following code in order to extract param value out of an existing url address func getQueryStringParameter(url: String, param: String) -> String? { guard let urlItems = URLComponents(string: url) else { return nil } return…
Zohar81
  • 4,554
  • 5
  • 29
  • 82
1
vote
2 answers

How to pass array to Postman as form-data

I have the following URL that I would like to test in Postman. However I would like to break down the array for easier testing for example as Form-data (or other). How would I setup this array in Postman? Full…
Paul S.
  • 1,342
  • 4
  • 22
  • 43
1
vote
1 answer

How to include accented characters in Swift URL without percent encoding?

I am trying to make a web request to a URL that needs to keep accented characters instead of percent encoding them. E.g. é must NOT change to e%CC%81. I cannot change this. These are the allowed characters that shouldn't be percent encoded:…
Kocsis Kristof
  • 74
  • 2
  • 10
0
votes
0 answers

Upload form-data with SwiftUI and Express backend

I want to upload some user data for register new users and I want to upload a profile picture. I'v tried with this code but it doesn't work, on my backend im just receiving a request with nothing like a form-data inside. This is my swift code func…
0
votes
3 answers

Unable to convert string to URL in Swift iOS

In order to make HTTP request call using URLSession,I need to convert string to URL first so I have tried everything but just can’t convert this piece of string to URL(string: ). This is the…
gagan sharma
  • 256
  • 1
  • 4
  • 18
0
votes
2 answers

How can I make URLQueryItem with large bracket ([])?

I need to make a URL with query parameter with large bracket. this is the example. https://samlpe.com/detail?item_code[]=smtwGBArkp3ByfrLK3KfxdoX I trying to use URLComponents and URLQueryItem. but URLQueryItem don't take array (["code"] in below)…
hiroshi046
  • 33
  • 5
0
votes
1 answer

Detecting a valid web address

I am trying to write some code that lets me both validate that a string is in fact a valid web address to reach a remote server && be able to unwrap it safely into a url for usage. From what gathered from various posts and Apple's source…
-1
votes
1 answer

iOS Swift API URLQueryitem

var urlComponents = URLComponents(string: "https://jsonplaceholder.typicode.com/users/") urlComponents?.queryItems = [URLQueryItem(name: "id", value: userId.id)] var urlComponents = URLComponents(string:…
-1
votes
1 answer

URLComponents init fails

I'm trying to create an URLComponents object so I can extract parameters values from a string. I have the string topic_id12&lessong_id=45: let dataString = "topic_id12&lessong_id=45" guard let urlComponents = URLComponents(string:…
Kex
  • 8,023
  • 9
  • 56
  • 129
-1
votes
1 answer

JSON URLComponents URLQueryItem Failure

I'm struggling with an http call for json data. If I use the entire URL as a string, the json fetch works. If I separate the call into URLComponents I have not been able to make it work. My Webservice: final class Webservice { var components:…
JohnSF
  • 3,736
  • 3
  • 36
  • 72