Google-api-dotnet-client: 404 on every call through BatchRequest

Created on 28 Aug 2020  路  24Comments  路  Source: googleapis/google-api-dotnet-client

I get 404 ("Response status code does not indicate success: 404 (Not Found).") on every call through BatchRequest.
What I mean, before I used BatchRequest and didn't specify custom batchUri:
var batch = new BatchRequest(service);
Since https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html I tried to use custom uri for each services. For eaxample for Youtube data API:
var batchRequest = new BatchRequest(service, "https://www.googleapis.com/batch/youtube/v3");
But on every call I heav got an error.
What I do incorrectly or it doesn't work at all ?
Thanks.

external p1 blocked bug

Most helpful comment

The API team has confirmed (with 100% certainty) that the fix is fully rolled out. I've been running my test code and @alenvall's all morning and I haven't seen any errors.
I'll leave this open until I hear from some of you, but this time this really should be working.

All 24 comments

Assigning to Amanda to look at when we return to work, but please be aware that Monday is a public holiday in the UK, so we probably won't get to this until Tuesday.

Hi, do you have any ideas about my issue? It's really blocker for us. Thanks.

I'll look at this tomorrow UK time.

(For future reference, here's the correct URL for the blog post about global batch endpoint depreciation: https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html)

Since https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html I tried to use custom uri for each services.

Why did you started adding the URL manually? Since you are using the Google.Apis libraries, you only had to update the library dependency, the newer library versions all point to the new batch URLs, this applies to Youtube and the rest of the APIs. See in the blogpost the section titled "Google API client libraries" (sorry, no direct link there).

For eaxample for Youtube data API:
var batchRequest = new BatchRequest(service, "https://www.googleapis.com/batch/youtube/v3");

This is the wrong batch URI for Youtube, the right one is "https://www.googleapis.com/batch/youtube", the examples on the blogpost are not exhaustive and not all URIs are built the same. But again, you don't need to add the URI manually, just make sure your Google libraries dependencies are up to date.

But on every call I heav got an error.
What I do incorrectly or it doesn't work at all ?

Yes, that's the correct error for a URL that does not exist.

If for some reason you can't update your Google libraries dependencies, which in any case I strongly encourage you to do, you can find the batch path for an API in its discovery doc. For instance, for Youtube:

Thanks for your answer but it doesn't work on my side. (Google.Apis.YouTube.v3 version is 1.47.0.2008)

` var request = service.Activities.List("snippet");
request.PublishedBefore = null;
request.PublishedAfter = null;
request.ChannelId = "UCKAqou7V9FAWXpZd9xtOg3Q";
request.MaxResults = 50;
var result = await request.ExecuteAsync();
// I've got a result here. Work's fine.

var batch = new BatchRequest(service, service.BatchUri);
// batchUri is "https://www.googleapis.com/batch/youtube"
batch.Queue(request, (content, error, index, message) =>
{
});

await batch.ExecuteAsync();
// but in batch I get the same 404 error as before.
`

Any ideas ?
Thanks.

That's interesting, let me try and reproduce it on my end.

I've reproduced the issue. I'm following up with the API team, there seems to be a mismatch between the batch URL specified on the discovery doc and the one that has been set up. There's not much we can do on the client library side though.
I'll leave this issue open for the time being while I find out more details so I can report back here.

This is being looked at internally. In the meantime, the only workaround is that you switch to making individual requests where possible. I'll keep updating here as I know more.

Any update on this? It's preventing us from fetching data required for business needs.

A fix is being tested and should start rolling out to prod after. As soon as I confirmed is out and working I'll update here.

This is still being looked at by the API team. As soon as it is working I'll update here.

Is there a workaround here that we are not aware of? cause it seems to me that if the whole youtube API no longer accepts batch requests there would be a solution available in less then a month? I just feel like there must be more than the two of us in this issue using the endpoint.

@petterannerwall The only workaround offered by the API team so far is to use individual request. I totally understand that this might not be a proper solution for you.
Also, on this repo there's really nothing we can do, appart from what I'm already doing which is following up with the API team. Bear in mind that we are resposible for the .NET client libraries and this is an issue with the API endpoint itself.
There are several similar issues open for the Youtube API team on the Issue tracker. You can add your comment there or create a new one.
Again, I will get back here as soon as I confirm is working, but unfortunately I can't offer an ETA.

Thanks, and sorry if I sounded rude, it's just frustrating. Thanks for pointing me in the right direction for the super quick answer!

No worries, I totally understand.
Also, some of the Batch related issues I linked earlier seem old, so they might be unrelated to this one particular failure. In any case, I think I'd be good if you created a new issue there, you can link to this one as reference.

No worries, I totally understand.
Also, some of the Batch related issues I linked earlier seem old, so they might be unrelated to this one particular failure. In any case, I think I'd be good if you created a new issue there, you can link to this one as reference.

Hi, two months have passed.
May be, do you have some news ?

Thanks,

There's a fix rolling out but still not fully out there yet. It's supposed to be fully rolled out by the end of this week. I've been trying my code every couple of days and I still hit the 404 from time to time. Hopefully they wait is almost over.

Finally this is consistently working for me. I'm waiting for internal confirmation that the change has been fully rolled out, but I expect it to be so.
I'll leave this issue open for a few days and until I get internal confirmation and hear from some of you that reported. Let me know if you encounter any issues.

Again, I'm sorry for the delay, but not much we could do on the libraries side of things.

I've gotten confirmation that the fix is indeed fully rolled out now. I'll close this issue now, but please do add a comment if you encounter any problems or batch is still not working for you.

Hey!

I'm using the the latest, stable version of Google.Apis.YouTube.v3 (1.49.0.2120) and executing the batch request returns 501.
The following snippet still produces an error for me:

var singleRequest = service.Channels.List("snippet");
singleRequest.Id = "UCKAqou7V9FAWXpZd9xtOg3Q";
singleRequest.MaxResults = 50;
var result = await singleRequest.ExecuteAsync(); // Works

var batch = new BatchRequest(service);  // batchUrl gets set to https://www.googleapis.com/batch/youtube/v3
var channelRequest = service.Channels.List("snippet");
batch.Queue<ChannelListResponse>(channelRequest, (response, error, index, message) =>
{
});

await batch.ExecuteAsync(); // 501

I feel like I may be missing or misunderstanding something.

Thanks!

@alenvall Actually I just ran into a 501 a few times trying to reproduce with your code and with mine as well. But it worked well some other times. Might just be that it really hasn't fully rolled out even though I got confirmation.
I'll report internally and I'll also try to reroute this issue directly to the API team so I'm not in the middle anymore, it is a waste of time for everyone. This is definetely not a library issue, but an API issue, and it seems not to be fully resolved.

I'll reopen this one until I have rerouted though so feel free to leave your comments here with other findings.

The API team has confirmed (with 100% certainty) that the fix is fully rolled out. I've been running my test code and @alenvall's all morning and I haven't seen any errors.
I'll leave this open until I hear from some of you, but this time this really should be working.

It's working on my end now!
Thank you!

I'll be closing this now having gotten a couple of thumbs up, but please don't hesitate to add another comment if you see any failures.

Was this page helpful?
0 / 5 - 0 ratings