Questions tagged [alamofire]
Alamofire is an HTTP networking library written in Swift.
6,070
questions
0
votes
0
answers
27
views
How do I decode json Dictionary into a struct that I want and use that data to populate my Table View
I have a data model which is a struct and I have an API which has json dictionary . I need to populate my table view cells with the values in the dictionary . I have already created an array ...
0
votes
1
answer
63
views
How can I get decoded data from a struct inside a struct from an API [closed]
I am trying to learn how to use AlamoFire and I want to get the values of structures inside this struct MyData. How to achieve this ?
import Foundation
import Alamofire
struct MyData : Codable {
...
0
votes
0
answers
31
views
How to resolve the warning "responseJSON is deprecated and will be removed in Alamofire 6"
I am using the following code block as a common network component in my project,
AF.request(url, method: method ?? .post, parameters: requestParameters, encoding: JSONEncoding.default, headers: ...
0
votes
2
answers
36
views
XCTestCase Multipart params with Alamofire using URLProtocolStub in Swift
I would like to know how can I test multipart sending params with Alamofire (network stack). Ex: send a string with an image (Data type).
My issue is that when I receive a response, I get the ...
0
votes
1
answer
51
views
jsonbin API problems with Swift
I'm building a little app that talks to the jsonbin API with Alamofire. Their API docs cover using Python to "put" or "update" the JSON file data extensively in Python. I'm ...
-1
votes
0
answers
20
views
Is there any "JSON Schema To POJO" for Swift? [duplicate]
I'm migrating an application from Android to IOS and right now I'm stuck at the part of finding an "automatic" way to transform a JSON response from a WebService into a Swift set of Objects ...
-1
votes
0
answers
21
views
Swift MultipartFormData from [String: Any] in swift using Alamofire
import Alamofire
extension MultipartFormData {
func importData(with parameter: Parameters, parentKey: String? = nil) {
for (key, value) in parameter {
let newKey = ...
-2
votes
0
answers
37
views
Alamofire - ResponseJSON deprecated
I'm using AlamoFire to communicate with my php/web-application and want to solve this annoying warning... My app is working fine but will become deprecated if i do not fix this.
.responseJSON { ...
0
votes
0
answers
18
views
Alamofire Skipping Requests
I used the following code to send an HTTP GET request
let request = AF.request("https://swapi.dev/api/films/?format=json") request.responseJSON { (data) in print(data) }
The code ...
0
votes
1
answer
33
views
Could not cast value of type 'Foundation.URLRequest' to 'Alamofire.URLConvertible'
I am trying to do a post request using Alamofire with a body:
let credential = URLCredential(user: appDelegate.username!, password: appDelegate.password!, persistence: .none)
var url =...
-1
votes
1
answer
43
views
Alamofire No exact matches in call to class method 'jsonObject'
I am using Alamofire like so:
let headers: HTTPHeaders = [
.accept("application/json")
]
let credential = URLCredential(user: "username", password: "p@...
0
votes
0
answers
62
views
Swift Alamofire multipartFormData 400 error
enter image description hereI tried to send multi part form data through Alamofire.
I've tried it over and over again, but the code is getting an error.
I found out that it was 400 error through ...
1
vote
0
answers
25
views
How to implement a smart response cache depending on the error in the response?
Good afternoon, Everyone!
I'm trying to make sure that the cache is used only for the scenario when I get an error in the response (not any error). Take data from the cache only if there is no ...
0
votes
0
answers
71
views
Error (Xcode, Swift): JSON could not be serialized because of error: The data couldn't be read because it isn't in the correct format
I made an app a couple years ago and am trying to update it now. When I run my Alamofire request, I am getting an message that, "JSON could not be serialized because of error: The data couldn't ...
-2
votes
2
answers
78
views
Parse Bool response using Alamofire
I have old code from team where they were failing to parse Bool response.
NetworkManager.shared().firebaseTokenService(request: APIRouter.firebasetoken(param as [String : Any]), completion: { (...
0
votes
0
answers
40
views
Swift. Alamofire doesn't send Bearer Authorization header with particular request
I have a request constructor:
AF.request(
baseURL.appendingPathComponent(path),
method: method,
parameters: parameters,
encoding: encoding,
headers: .init([....
0
votes
1
answer
51
views
Alamofire's callback block cannot run, i'm sure the server received the request send by Alamofire
Alamofire's callback block cannot run, i'm sure the server received the request send by Alamofire
here‘s the code:
import Alamofire
import Foundation
@main
public struct SwiftClient {
public ...
0
votes
1
answer
61
views
API response got error -1004, -1001, -1020 frequently- iOS
Our users receive errors -1001, -1004, or -1020 frequently but not at all ( about 1% of the requests). Still, I don't have any idea why it happens they have a strong internet connection at that time ( ...
0
votes
0
answers
18
views
Alamofire not being installed properly - unable to properly code https request for Watch
I'm currently trying to send an https request from an Apple Watch to an iPhone using Alamofire, which I understand is the only way to do this. I've tried installing using Cocoapods, but this hasn't ...
0
votes
1
answer
53
views
Encode a string as httpBody via URLEncodedFormParameterEncoder
I have a POST login API that accepts password parameter as a simple string in httpBody.
This is like swagger call appears:
Now, I'm using Alamofire, and I want to encode it in my URLRequest via ...
0
votes
0
answers
21
views
Swift Nested array object POST with Alamofire Error
I have this code:
var painBody: [PutPainBody]? = nil
if let pains = physicalConditionData.pains {
painBody = []
for pain in pains {
let painData = PutPainBody(
...
0
votes
0
answers
95
views
Fetching list of items always times out after 60 seconds
I am fetching a list of items using Alamofire and Promisekit. Some items take longer to get than others. I have set the timeout in alamoFireManager to 180 seconds, however 60 seconds after the first ...
0
votes
1
answer
84
views
This swift code is not working, can someone tell me what i am doing wrong?
I a'm working in a old project
This code is not working, can someone tell me what i am doing wrong ?
The json is returning from API, but the object is not being created (parsing json to class)
podfile
...
1
vote
0
answers
30
views
Library not loaded: @rpath/Alamofire.framework/Alamofire Swift
I am making build of my project, but i am not able to make build because some errors accors like
dyld[42806]: Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: <09986113-...
1
vote
1
answer
58
views
Generic parameter 'T' could not be inferred Alamofire
Following the Alamofire Documentation for multipart form data uploads the request should be something like this:
AF.upload(multipartFormData: { multiPart in
multiPart.append(data!, withName: "...
0
votes
1
answer
75
views
Alamofire how to parse JSON in Swift?
I used Alamofire's GET function to return this JSON from API.
Here's how I used Alamofire:
struct Params: Encodable {
let code: String
let codeType: String
}
...
0
votes
0
answers
115
views
Alamofire 5 multiple token refresh issue in AuthenticationInterceptor
After changing public and private keys for jwt token (on the server), Alamofire interceptor for authorization is triggering token refresh multiple times and after that calls next API Call without ...
0
votes
1
answer
50
views
Problems with Alamofire and Swift closures
I have the following class with a function that returns a boolean value using alamofire.
class Productos: Codable{
// MARK: Propiedades de los productos
var id_producto : String = "&...
1
vote
0
answers
89
views
Unexpected Crash when Handling Alamofire DataRequest Response
I get a crash in Alamofire on iOS devices (iPhone XR, iPhone 13Pro), but don't get on the simulator or when I run as a Mac App.
All iOS devices (both Simulator and Actual devices) all on iOS16.4.x
It ...
2
votes
1
answer
260
views
Pros and Cons Alamofire Concurrency vs Regular or suggested method
Can some explain me the pros and cons about Alamofire Concurrency and Alamofire regular suggested method?
Concurrency way
func getDataConcurrency() async throws -> SomeModel {
let dataTask = AF....
0
votes
0
answers
63
views
By using Alamofire, I want to upload a video file
I need to upload a video to server using Alamofire. The user selects the video from device and I get URL in didFinishPickingMediaWithInfo successfully as follows:
func imagePickerController(_ picker: ...
0
votes
1
answer
70
views
Download zip fil and unzip it using Alamofire in Swift
I have a zip file of assets in AWS S3 bucket. I want to download that zip file using Alamofire and unzip and save in my device. I am using Swift. Please help.
func downloadFile(url : URL, ...
0
votes
0
answers
174
views
Alamofire stream requests consistently fail if invoked after 1-3 minutes
I've built a macOS app that integrates with ChatGPT. To support the model's streaming responses, I'm using Alamofire's AF.streamRequest to continuously update a label on screen. It looks something ...
0
votes
0
answers
93
views
Alamofire doesn't limit MultipartFormData's InputStream upload length to MultipartFormData.BodyPart.bodyContentLength
When I upload a large file, the entire file is uploaded in a single shot, which is not what I expect since I've set MultipartFormData.BodyPart.bodyContentLength.
I'm trying to upload a slice of length ...
-1
votes
2
answers
76
views
How can I mock the Alamofire Extension on UIImageView?
Alamofire has an extension on UIImageView that makes loading an image very easy. But, for unit testing my code, I would like to mock the result of the response, so that I can test success and failure. ...
1
vote
1
answer
60
views
keyNotFound Swift Alamofire [duplicate]
Model Class
public struct Products : Codable {
let data: [ProductData]
let error: Bool
let message: String
}
public struct ProductData : Codable {
let id, category, subCategory, name, ...
0
votes
0
answers
427
views
URLSessionTask failed with error: A server with the specified host could not be found
I have an iOS app that uses Alamofire to make network requests. Some of my users are reporting that they are unable to use the app and receive the following error message (when sending request to our ...
0
votes
0
answers
51
views
Alamofire responseDecodable array of object fails if can't create a single object [duplicate]
In my app, I'm using Alamofire as network library.
I have an object like this (all properties are non-optional)
struct User: Codable {
let name: String
let email: String
let role: String
}
...
0
votes
0
answers
42
views
retry alamofire request when I get statusCode 401
i have request builder with alamofire, and sometimes I have 401 statusCode (about token what need to refresh).
how do I need to change the class network in order to be able to refresh the token and ...
0
votes
1
answer
132
views
Sending an image to api using URLRequest or Alamofire in Swift
(Swift 5 / Alamofire 5 / Xcode / IOS)
I'm trying to send a photo I took to the mathpix api. This is how it is shown in mathpix's api documentation:
curl -X POST https://api.mathpix.com/v3/text \
-H '...
0
votes
1
answer
76
views
How to handle errors globally in Alamofire?
I have a api where users roles can expire, at which point every request will return a 410 error code.
I'd like a global handler to reset some data, prompt UI to reset, etc.
What's best suited hook ...
0
votes
1
answer
133
views
Alamofire Failure - responseSerializationFailed
func postAd(cryptoo: String, fiatt: String,locationn: String,countryy: String,marginn: String,
pricee: String,minlimitt: String,maxlimitt: String,paymrntwindoww: String,paymrntmethodd: ...
0
votes
1
answer
135
views
Getting Urlsessiontask failed with error: the request timed out with blank screen RxSwift in swift
I am using RxSwift in swift. When my server is close it shows below error with blank screen. I have used a alert. But I have to click too many time to close the alert here is the error
I have ...
0
votes
1
answer
65
views
How to encode characters in url with Alamofire on iOS
I'm using Alamofire as network manager in my iOS App.
I need to do a GET request and send a value like this
DQIOE/LE/G77qpYbiMQPIuND2qrZjhS4f6kMDSr1+Zjxrq31QjdZZPNtbNjdmBBO3bHCJD8J+...
-2
votes
1
answer
33
views
AlamoFire response back in JSON failing Swift
I have the following code:
let request = AF.request(GET_SEARCH_API)
request.responseJSON { (data) in
print("SEARCHED RESULTS: \(data)")
let JSON = data as! ...
0
votes
0
answers
27
views
ObjectMapper Int and Double returns zero always
Using Alamofire to call API returning json response with ObjectMapper to map according to their documentation found on github https://github.com/tristanhimmelman/ObjectMapper I can use Double and Int ...
0
votes
1
answer
269
views
framework does not contain bitcode ... for architecture arm64
I am using macbook air M1 and xcode 14 I try to compile my project with having carthage as dependency manager with dependency Alamofire 4.9.1 . everytime I archive for arm64 devices I get '/somePath ...
0
votes
1
answer
50
views
Is there an another way to call retry funcation except response code equal 400- 500 when i using RequestInterceptor of Alamofire
I want to refresh the token when it expires, but the server returns 200 not 401 so the retry method will not execute.
Is there a way to manually call retry? Or some other solution?
0
votes
1
answer
395
views
Alamofire 5: Upload Failed: Response could not be decoded because of error: The data couldn’t be read because it is missing
As the title says, Alamofire 5 is telling me that the data is missing, yet it is not.
This is the data I have in my console along with the error
dic=== {"lat": "26.9342246", "...
0
votes
1
answer
116
views
seeking Alamofire response as string, but response is always nil [duplicate]
I'm trying to download some HTML from a website, parse it,
and display it in a grid. The HTML isn't formatted very well,
so I've already written an init() method that parses that
HTML as a String.
My ...