Reputation: 713
I'm trying to run the Quickstart in Python for the Group Migration API.
The goal is to insert a message to a Google group that I created for testing.
I've created a Google for Work account, and made a Google group that is owned by admin.
I created the credentials in console as "Client ID for Other" and set them up on my client.
When I run the script, I get:
googleapiclient.errors.HttpError:
<HttpError 400 when requesting
https://www.googleapis.com/upload/groups/v1/groups/test-migration-business%40googlegroups.com/archive?uploadType=media&alt=json
returned "com.google.gaia.client.InvalidUserIDException:
Request for GaiaClientConst::INVALID_USERID">
The authorization flow appeared to work fine. I get the confirmation in the browser tab. It creates the credentials file in my local directory.
I am authorizing as the admin user of the Google for Work account. I've enabled API access in the admin.google.com console. I've also been through the Prerequisites steps, and I think it's all set up OK.
Any idea what causes this?
Edit: I got some more information through another channel. The problem was with the group to which I was trying to post via the API.
It's not just about creating the group under a Google Groups for Business account. You have to go through a lot of setup in the admin.google.com panel. Eventually when you set it up right, you can create a group whose e-mail address is of the type: [email protected].
As long as it's creating your groups with the @googlegroups.com suffix in the e-mail address, the API call won't work.
I will write an alternative answer in a couple of days once I've explored doing this with SMTP e-mail adds instead.
Upvotes: 0
Views: 498
Reputation: 713
The problem was with the group to which I was trying to post via the API.
It's not just about creating the group under a Google Groups for Business account. You have to go through a lot of setup in the admin.google.com panel. Eventually when you set it up right, you can create a group whose e-mail address is of the type: [email protected].
As long as it's creating your groups with the @googlegroups.com suffix in the e-mail address, the API call won't work.
I went down the path of using SMTP to post to a public group as per these links: https://github.com/jmuhlich/mailman-archive-migration https://gist.github.com/tdonohue/cd2a643c5fca5f140cfd
I encountered some difficulties with the SMTP approach and eventually abandoned it.
a) You need to load messages in chronological order, as they post with the current date/time when you add them. They can get out of order if the e-mail gets held in moderation queue as spam and approved later.
b) There's now a very low limit on Google's SMTP relay, unless you have a big bucks Google Apps account with a large number of subscribed users. The SMTP relay service becomes important so that your archived messages don't get marked as spam on the way in to the group.
I have gone back to the API solution and have almost finished it. It took a bit of time to get encoding of charsets to work right in all cases. But otherwise it works well.
Upvotes: 0
Reputation: 6791
It may be caused by INVALID MESSAGE FAILURE — The email message is in an invalid format. If a message is rejected as malformed, you'll receive a 400 Bad Request HTTP status code. Invalid format examples include:
- The message could have missing From, To, and Date fields.
- An error occurs if a line in the message is not terminated by a CR+LF (that is, "\r\n") style newline.
- The email message is empty.
- The migration's target group does not exist or is in 'read-only' mode. For more information about the read-only sharing mode, see the Google Groups for Business sharing options.
It may also be UNSUPPORTED_PARALLEL_OPERATION — The API does not support parallel message insertions into the same group archive. Nor are batch requests supported in this version of the API. But the API supports parallel requests for email insertions into different group archives. A 400 HTTP status code is returned.
Double check the request form and Managing Email Migrations to see important notes for migration.
Hope this helps!
Upvotes: 1