prowdsponsor / ig

Bindings to Instagram's API
Other
11 stars 14 forks source link

Fix JSON exception #14

Closed potomak closed 9 years ago

potomak commented 9 years ago

There is a corner case where, if a user tries to set a relationship using their own id, Instagram API returns a successful response that doesn't include any data, leading to a JSONException.

Running these instructions in a cabal repl:

:set -XOverloadedStrings
:m +Network.HTTP.Conduit
:m +Control.Monad.Trans.Resource
let creds = Credentials "" ""
let userId = "XXX"
let selfId = "YYY"
let user = User "" "" "" Nothing Nothing Nothing Nothing
let oAuthToken = OAuthToken (AccessToken "ZZZ") user
let setSelfRelationShipAction = setRelationShip selfId oAuthToken Follow
manager <- newManager tlsManagerSettings

the expression

runResourceT $ runInstagramT creds manager setRelationShipAction

returned

*** Exception: JSONException "Relationship"

With this fix the same expression now returns

Envelope {eMeta = IGError {igeCode = 200, igeType = Nothing, igeMessage = Nothing}, eData = Nothing, ePagination = Nothing}

See also https://instagram.com/developer/endpoints/relationships/#post_relationship

meteficha commented 9 years ago

Looks good, thanks! Sorry for looking at this earlier. Released as ig-0.4.