[ad_1]
I am engaged on an organization mission who use Alamofire to hook up with a Dittofi API.
I am getting a 0 standing code and a weirdly null output. Heres the code (I can solely launch this as per my NDA):
self.supervisor.add(multipartFormData: {
multipartFormData in
for (key, worth) in params{
multipartFormData.append(worth.information(utilizing: .utf8)!, withName: key)
}
}, to: createAssignmentURL, encodingCompletion: {
(outcome) in
change outcome {
case .success(let add, _, _):
add.responseJSON {
response in
change response.outcome {
case .success(let j):
let json = JSON(j)
print("JSON: ", json)
let message = json["statusMessage"].stringValue
let standing = json["statusCode"].intValue
let information = json["data"]
if standing == 200{
completion(message,"",standing)
}else{
let errorMessage = information["error_msgs"].stringValue
self.reportError(message: errorMessage)
completion(errorMessage,"",standing)
}
case .failure(let error):
if error._code == NSURLErrorTimedOut {
completion(App.CONNECTION_TIMEOUT,"",App.STATUS_TIMEOUT)
}
else if error._code == NSFileNoSuchFileError {
completion(App.INVALID_RESPONSE,"",App.STATUS_INVALID_RESPONSE)
}
else {
completion(App.INVALID_RESPONSE,"",App.STATUS_INVALID_RESPONSE)
}
}
}
case .failure(let error):
if error._code == NSURLErrorTimedOut {
completion(App.CONNECTION_TIMEOUT,"",App.STATUS_TIMEOUT)
}
else if error._code == NSFileNoSuchFileError {
completion(App.INVALID_RESPONSE,"",App.STATUS_INVALID_RESPONSE)
}
else {
completion(App.INVALID_RESPONSE,"",App.STATUS_INVALID_RESPONSE)
}
}
})
Heres the output:
JSON: {
"information" : null,
"error" : {
"message" : "",
"param" : "",
"code" : "e_invalid_json"
}
}
I am sure one thing is mistaken with the way in which I publish however I cant appear to determine it out. I additionally get a 0 standing code which apparently implies that the response is empty. Is that this an issue with my code or the API?
[ad_2]
