Method HTTP 405 Not Allowed error on PostAsync with Google Spreadsheets

I’m a developer for a small closed community which relies on Google Spreadsheets for specific goals like storing player data across multiple games. I’m fully aware that Google Spreadsheets do not serve as a database and as the only reason this is being used is because as I said it’s a small community, thus spending extra money on a proper one is expensive compared to this.

The database system stores all the player data in a JSON encoded value per player key which has significantly reduced the amount of HttpRequests the system used to create per sheet.

This problem has occured once in 2018 which was shortly fixed 2 weeks later. We assumed this was the case for the problem again, however it wasn’t.

The issue itself is that we can retrieve data via GetAsync but cannot edit data via PostAsync. This is a confirmed Roblox issue as using the url that usually gets sent in the Lua code for PostAsync(url) in Chrome seems to work seamlessly and from what I’ve head HTTP 405 is a client error. Do correct me if I’m mistaken.

The bug happens in normal games as well as in the Roblox Studio application. Before this all happened there was an occurance where you couldn’t use PostAsync with it in Studio, but could in-game.

It firstly occured 7th of July at 5:16PM Central European Time.

image

Other Groups in the community seem to be having the same issue.

The url key is structured as https://script.google.com/macros/s/APIKEY/exec and the arguments and information that needs to get passed on is added on to the link upon request.

This system was set up by using this tutorial:

1 Like

Did you try on an external API tester to check if it was just from Roblox? If not it would be a good idea to do that before assuming it’s an engine bug.

You can’t test it straight in Chrome because it will do a get request, not a post request.

You need to recreate the exact request, with your sheet, key and data encoded just as it would in the Roblox request. The easiest way to grab this is to just do a print call of the fully constructed URL and then copy and paste that into the API tester. Ensure you select POST method. If you get 405 there too, you know it’s an issue with the API and you may need to take a look at Google’s documentation.

1 Like

Yes I have. GetAsync worked perfectly fine as well as PostAsync in multiple of those API testing websites.

1 Like

Well as far as I can tell, it’s Google rejecting the request. 405 is a common one when using an endpoint that doesn’t exist, using the wrong method for an endpoint (e.g. POST instead of PUT), or specifying the wrong content-type header.

I suspect that you haven’t fully recreated the request with all the same headers and parameters in the API testing websites otherwise it should return the same. Make sure you’ve got everything down to a tee, including the Content-Type header, any postdata, and the exact endpoint with your key and all the parameters.

If they had blocked Roblox for some reason it wouldn’t be a 405. If it was an issue on Roblox’s side before making the request, it would error without a HTTP response code.

Can you link me to a quick article or tutorial about getting set up with this? I’d like to make a quick demo myself to have a check for you. I was a web developer for quite a long time and it might be something simple that we’re missing here that I’ll find when playing about with it.

1 Like

Putting this in the post as well.

1 Like

You’ll notice the creator doesn’t support the module anymore. The API has changed since then.

If you use APITester as I suggested, you’ll see that it redirects the request (and also doesn’t return JSON data as a result of the redirection).

Roblox will follow that redirect, and if you run that redirected URL in the tester, you get a 405 response, just like on Roblox. As I said, it’s not a Roblox issue or a client issue, it’s the Google API issue.

Why 405? Well if you look at the response of the redirected URL, you’ll see it says it only accepts HEAD and GET requests, not POST requests:
image

That said, if you stick the parameters into the URL rather than the postdata body, by doing httpService:PostAsync(url .. "?sheet=" .. sheet .. "&key=" .. key .. "&value=" .. json, '', 2) then it does update the data, but still results in a 405 method not allowed.

There’s no header or other method that you can use to prevent the redirection, which is quite annoying in this specific case, as it seems to set the data correctly before redirect, if you use the URL method above.

Unfortunately this is just a problem with the API and you can see this by using the search bar here on the DevForum and seeing people report this back in November 2019 here and here.

It’s up to you whether you want to press ahead and ignore the 405 errors now that you’ve got a way for it to save, but it’s not a good idea as you have no visibility into whether it saved correctly or not, as any downstream errors are masked by the 405 response.

As suspected, this is not a Roblox engine bug at all, it’s returning exactly what is returned when performing the request elsewhere - Roblox just skips telling you about the 302 response and jumps straight to the final 405.

5 Likes

Not a bug, see Method HTTP 405 Not Allowed error on PostAsync with Google Spreadsheets - #6 by BanTech