2

xcode 10.3 swift 4.2 iPhone 应用程序

我正在使用一个帖子类型的 API 来上传图像以及表单中的一些字符串数据。我得到了成功的响应结果,但是有一个错误参数表明:CredStore - performQuery - Error copying matching creds. Error=-25300

我尝试做一些研究,发现我有问题,URLCredentialStorage但我在 API 中没有任何凭据。我查看了CredStore Perform Query error,我遇到了非常相似的问题,但在那里找不到我的解决方案。

{
    let url = route.asURL(constants: constants)
    let parameters = route.asParameters(constants: constants)
    let headers: HTTPHeaders = [
        "authorization-name": APISession.token,
        "Content-Type": "multipart/form-data"
    ]

    Log(request: URLRequest(url: url))

    Alamofire.upload(multipartFormData: { (multipartFormData) in
        for (key, value) in parameters {                
            if let strValue = value as? String, let valueData = strValue.data(using: .utf8) {
                multipartFormData.append(valueData, withName: key)
            }

            if let imgValue = value as? UIImage, let imgData = imgValue.jpegData(compressionQuality: 0.5) {
                multipartFormData.append(imgData, withName: key, mimeType: "image/jpg")
            }
        }
    }, usingThreshold: UInt64.init(), to: url, method: .post, headers: headers) { (result) in
        print(result)
        switch result{
        case .success(let upload, _, _):
            upload.uploadProgress(closure: { (progress) in
                print("Preogress is: ", progress.fractionCompleted)
            })
            upload.responseJSON { response in
                print("Succesfully uploaded")
                switch response.result {
                case .success(let value):
                    print(value)
                case .failure(let error):
                    print(error)
                }
            }
        case .failure(let error):
            print("Error in upload: \(error.localizedDescription)")
        }
    }
}

我得到这样的回应,

success(request: 2019-08-12 13:07:04.224913-0400 project name[65508:460860] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "url";
    srvr = "url";
    sync = syna;
}

所以我很困惑为什么我会收到success带有错误参数的响应。

4

1 回答 1

0

不确定,但我认为authorization-name标题中存在的密钥不正确。应该是Authorization

于 2019-08-22T06:40:00.030 回答