egg-mode-rs / egg-mode

a twitter api crate for rust
https://crates.io/crates/egg-mode
Mozilla Public License 2.0
372 stars 65 forks source link

"missing field `target`" in user::relation #96

Closed Muirey03 closed 4 years ago

Muirey03 commented 4 years ago

Consider the code:

let relation = user::relation("twitter", "jack", &token).await;
println!("relation: {:?}", relation);

This outputs:

relation: Err(DeserializeError(Error("missing field `target`", line: 1, column: 531)))

Other functions such as user::show work correctly, I only experience this error with user::relation.

The output of twurl --json-pretty '/1.1/friendships/show.json?source_screen_name=twitter& target_screen_name=jack' is:

{
  "relationship": {
    "source": {
      "id": 783214,
      "id_str": "783214",
      "screen_name": "Twitter",
      "following": false,
      "followed_by": true,
      "live_following": false,
      "following_received": null,
      "following_requested": null,
      "notifications_enabled": null,
      "can_dm": true,
      "blocking": null,
      "blocked_by": null,
      "muting": null,
      "want_retweets": null,
      "all_replies": null,
      "marked_spam": null
    },
    "target": {
      "id": 12,
      "id_str": "12",
      "screen_name": "jack",
      "following": true,
      "followed_by": false,
      "following_received": null,
      "following_requested": null
    }
  }
}

Please let me know if I am doing something incorrectly.

QuietMisdreavus commented 4 years ago

Looks like this one was lost in the Serde conversion. The old rustc-serialize code loaded everything through that "relationship" field and discarded that wrapper object, but that was lost when it was replaced with a #[derive(Deserialize)] implementation. I've posted https://github.com/egg-mode-rs/egg-mode/pull/100 which fixes this.

Muirey03 commented 4 years ago

Thank you, I can confirm that this commit resolved my issue. Would you prefer me to close this issue or leave it open until the changes are live?

QuietMisdreavus commented 4 years ago

I'll close the issue when i merge the PR. Thanks for confirming!