Need some help with using the google-datastore1 crate

I am trying to use the google-datastore1_beta3 crate to do some basic CRUD operations. There aren’t many examples, but the docs seemed simple enough. I could get operations working and it retrieves entities. But trying to use an upsert or insert operation results in a 400 Bad Request error. The code is:

pub fn upsert(&self, entity: Entity) -> std::result::Result<Option<Key>, Error> {
        let req = CommitRequest {
            transaction: None,
            mutations: Some(vec![
                Mutation {
                    insert: None,
                    delete: None,
                    update: None,
                    base_version: None,
                    upsert: Some(entity)
                }
            ]),
            mode: Some("NON_TRANSACTIONAL".to_string())
        };
        println!("{:?}", req);
        let result = self.ds.projects().commit(req, &self.project).doit();
        match result {
            Ok((_, commit_response)) => {
                if let Some(mut_results) = commit_response.mutation_results {
                    match mut_results.first() {
                        Some(mr) => Ok(mr.key.clone()),
                        None => Ok(None)
                    }
                } else {
                    Ok(None)
                }
            },
            Err(e) => {
                Err(e)
            },
        }
}

I’ve also made a small repo to reproduce the issue, please see: https://github.com/n-k/dstest/blob/master/src/db.rs#L32

Has anyone had success with using this crate?

I ran into this exact issue today, have you found a solution? I was able to successfully execute a commit through the Google Cloud API Explorer, but the same commit fails through google-datastore1. I fear it may be an issue with the crate.

Unfortunately, no. Haven’t found a solution yet. Like you, I could do a commit through API explorer. This definitely seems to be a bug in the crate. I’ve logged an issue here: https://github.com/Byron/google-apis-rs/issues/226