TheM4hd1 / SwiftyInsta

Instagram Private API Swift
MIT License
225 stars 51 forks source link

Media Upload Failed with Status Code 500 #119

Closed mehroozkhan closed 4 years ago

mehroozkhan commented 5 years ago

Sometimes Media Upload function failed with response :

<NSHTTPURLResponse: 0x281fa01a0> { URL: https://i.instagram.com/api/v1/media/configure/ } { Status Code: 500, Headers {
    "Cache-Control" =     (
        "private, no-cache, no-store, must-revalidate"
    );
    "Content-Language" =     (
        en
    );
    "Content-Length" =     (
        54
    );
    "Content-Type" =     (
        "application/json; charset=utf-8"
    );
    Date =     (
        "Sun, 27 Oct 2019 20:33:36 GMT"
    );
    Expires =     (
        "Sat, 01 Jan 2000 00:00:00 GMT"
    );
    Pragma =     (
        "no-cache"
    );
    "Set-Cookie" =     (
        "csrftoken=Oigux4dghhFezUy4j20AT7Xvm9cpKZKn; Domain=.instagram.com; expires=Sun, 25-Oct-2020 20:33:36 GMT; Max-Age=31449600; Path=/; Secure",
        "rur=FRC; Domain=.instagram.com; HttpOnly; Path=/; Secure",
        "urlgen=\"{\\\"58.65.212.48\\\": 9541}:1iOpEG:KEKssAYLJRYot0JG_CwbWFLnHEk\"; Domain=.instagram.com; HttpOnly; Path=/; Secure"
    );
    "Strict-Transport-Security" =     (
        "max-age=31536000"
    );
    Vary =     (
        "Accept-Language, Cookie"
    );
    "access-control-expose-headers" =     (
        "X-IG-Set-WWW-Claim"
    );
    "content-security-policy" =     (
        "report-uri https://www.instagram.com/security/csp_report/; default-src 'self' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src 'self' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src 'self' https://www.instagram.com; script-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' https://*.www.instagram.com https://www.instagram.com 'unsafe-inline'; connect-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src 'self' blob: https://www.instagram.com; frame-src 'self' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'; upgrade-insecure-requests"
    );
    "x-aed" =     (
        11
    );
    "x-content-type-options" =     (
        nosniff
    );
    "x-fb-trip-id" =     (
        1679558926
    );
    "x-frame-options" =     (
        SAMEORIGIN
    );
    "x-xss-protection" =     (
        0
    );
} }

My Code:

let picture = Upload.Picture(image: image, caption: caption, size: image.size)
        guard let handler = apiHandler else {
            completion(false)
            return
        }
        handler.media.upload(photo: picture) { (result) in
            switch result {
            case .success ( _):
                completion(true)
            case .failure(let error):
                completion(false)
            }
        }
sbertix commented 5 years ago

Does #96 fix this? @mehroozkhan

mehroozkhan commented 5 years ago

@sbertix how can I install the library from this branch ?

sbertix commented 5 years ago

Are u using CocoaPods or the Swift Package Manager? @mehroozkhan

CocoaPods

pod 'SwiftyInsta', :git => 'https://github.com/TheM4hd1/SwiftyInsta.git', :branch => 'sb/development'

instead of pod 'SwiftyInsta'

Swift Package Manager

Just remove the Package and add sb/development instead when prompted.


Remember the branch you're switching to is still under development and not final in any way

mehroozkhan commented 5 years ago

@sbertix thank you,

sbertix commented 5 years ago

Have you had any chance to test whether the error has been fixed in #96? @mehroozkhan

mehroozkhan commented 5 years ago

@sbertix In #96 every upload failed with error : Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}

sbertix commented 5 years ago

I guess I need to check that too then hahaha Cause it used to have a fix for #111, but apparently something has changed Instagram-side (most likely) 😭 @mehroozkhan

mehroozkhan commented 5 years ago

Looking forward for the fix :) @sbertix

sbertix commented 4 years ago

Unfortunately, we had to temporarily remove all upload functions from SwiftyInsta, due to Instagram changing their actual endpoints.
I'll update you if a fix is found. @mehroozkhan Apologies