Dima Grib2018-11-19 02:55:42
Dima Grib, 2018-11-19 02:55:42

Alamofire and Get request. How to implement correctly?

Friends tell me
1. There is such a request, in response to which I receive JSON


2. Tried to do it by
guard var url = URLComponents(string: str) else { return }
    url.queryItems = [
            URLQueryItem(name: "query_hash=", value: "\(queryHash)"),
            URLQueryItem(name: "\(str2)variables", value: "{"),

3. After that, I did the replacement of elements for the correct ulr through
url.percentEncodedQuery = url.percentEncodedQuery?.replacingOccurrences(of: "%3D=", with: "=")
    url.percentEncodedQuery = url.percentEncodedQuery?.replacingOccurrences(of: "%2522", with: "%22")

4. With percentEncodedQuery on chars such as - {} []everything crashes
5. I also tried to do everything in another way
var urlString: String = "https://www.yandexxx.com"
urlString = urlString.appendingFormat("/graphql/query/?query_hash=" + "\(queryHash)")
        urlString = urlString.appendingFormat("&variables={")
        urlString = urlString.appendingFormat("%22reel_ids%22:[\(userId)],")

But I can't complete this task correctly. I would be grateful for hints

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Alexander Semchenko, 2018-11-19

Hint: GraphQL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question