Cannot use `fields_attributes` inside `UpdateCredentialsInputOptions`
Closed this issue · 3 comments
Hi,
Maybe I’m mistaken or misusing it somehow, but I can’t make fields_attributes
function properly within the UpdateCredentialsInputOptions
(the rest of the Struct functions properly AFAIK, but not this particular field).
I tested this against version 0.2.5 and version 0.3.0
Code snippets:
#[tokio::main]
async fn main() {
let client = generator(
megalodon::SNS::Mastodon,
URL.to_string(),
Some(TOKEN.to_string()),
None,
);
let update_creds = UpdateCredentialsInputOptions {
fields_attributes: Some(vec![CredentialsFieldAttribute {
name: "Test".to_string(),
value: "test".to_string(),
}]),
..Default::default()
};
client
.update_credentials(Some(&update_creds))
.await
.unwrap();
}
Current behavior
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RequestError(reqwest::Error { kind: Builder, source: Custom("unsupported value") })', src/main.rs:28:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected behaviour
Adds the Test
/test
values inside the fields_attributes
API calls.
If you need any further information or if I can help somehow, please let me know.
I fixed it, please try the latest release!
It doesn’t fail anymore (good!) but it doesn’t update the fields (I honestly don’t know why…).
OK, I think I found it: according to the documentation, you should not provide an array but a dict of some sorts.
I’ve tested it with some static values and it seems to work properly. I’ll see if I can provide a PR to correct this.