我的問題基本上是在標題中。我試圖運行的代碼就在下面。 VVV[Swift,Alamofire]:responseValidationFailed,錯誤代碼爲400
let unfollow = "https://api.instagram.com/v1/users/\(userID)/relationship?access_token=\(access_token)&action=unfollow"
Alamofire.request(unfollow, method: .post).validate().responseJSON(completionHandler: {
response in
switch response.result {
case .success(let value):
let data = JSON(value)["data"]
print(data["outgoing_status"].stringValue)
case .failure(let error):
print(error)
}
})
確切的控制檯錯誤我收到的是:responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(400))
我使用順便把Instagram的API,但我不認爲這必然涉及到這個問題。
任何幫助非常感謝。
你可以檢查'unfollow'變量的值並將其添加到帖子中。我懷疑你在字符串中有一堆'Optional(...)'。 – user28434