I’m getting the same error.
I’ve just updated the Fabric twitter from 1.13 to 1.15.1 and started to get that error.
I already change my code to set the multidata but still getting the same error
[0] (null) “NSErrorFailingURLKey” : “https://upload.twitter.com/1.1/media/upload.json”
[1] (null) “NSLocalizedDescription” : “Request failed: unauthorized (401)”
[2] (null) “NSLocalizedFailureReason” : “Twitter API error : Could not authenticate you. (code 32)”
That’s my piece of code
Twitter.sharedInstance().logInWithCompletion { session, error in
if (session != nil) {
Log("signed in as \(session!.userName)")
let client = TWTRAPIClient(userID: session!.userID)
let data = UIImageJPEGRepresentation(image, 0.9)
let imageString = data!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
var imgRequest = client.URLRequestWithMethod("POST", URL: "https://upload.twitter.com/1.1/media/upload.json", parameters: ["media":imageString], error: nil)
//fix twitter image upload
let mutableRequest: NSMutableURLRequest = imgRequest.mutableCopy() as! NSMutableURLRequest
let boundary = self.generateBoundaryString(20)
mutableRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
imgRequest = mutableRequest.copy() as! NSURLRequest
SVProgressHUD.show()
client.sendTwitterRequest(imgRequest, completion: { (response, data, error) -> Void in
//HERE WHERE I GET THE ERROR (response and data are nil)
(...)
})
}else{
print("session error")
}
}