-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google Forms API expects JSON, not HTML #285
Comments
Did you do this to see if it reveals more about the error?
|
This is characteristic of sending a request that generates an HTML error from the API, which, if memory serves, is often more about auth than the request itself. But in any case, the error is not about sending JSON vs HTML to the Forms API. This is a 404 for the request and, when we try to handle and display the error, the payload is HTML, not JSON. Which is why the URL to that temp file is provided, so you can perhaps see more about the error. |
Hi! I did look at that error file. Gives this:
So you're right, it does seem to be an API error. Now it's up to me trying to figure out where :D. If it is more about the auth side of things, do you think it makes a difference that I am "running" in two different environments? My project is a shiny app so I'm using non-interactive, non-caching auth for that but when testing the API and the functions of |
If the "non-interactive, non-caching auth" is as a service account, that could definitely be the problem. You would need to make sure that the service account has been granted all necessary permissions on the relevant resources (Drive files, Sheets, etc.). The permissions will not be conferred on a service account indirectly, i.e. because you have permission and you control the service account. So that's one possibility, for sure. |
It's not a service account, as far as I know (I didn't set one up). The Shiny app uses my own OAuth2 client I created with Google. But my issues are occurring with the interactive case. I wonder if I should try things inside of the Shiny app (which has the OAuth client hooked up) instead. I do have the Sheets API, Drive API, and Forms API turned on with my client but I suppose I'm not sure if the necessary permissions are enabled when I try interactively. Good to know this isn't a |
This sentence doesn't fully make sense to me -- i.e. it doesn't tell a whole story, really:
An OAuth client is 1 out of the 3 legs of 3-legged OAuth, but a user still needs to use the client to obtain a token (Google's servers are the last of the 3 legs). And that token is what gets sent with the request. Does your Shiny app facilitate auth by a user? Maybe insert a |
My apologies, I should have been clearer there. Still learning how this process works :). You are correct, the client prompts a user to sign in via a browser and creates a token for use. I do have a However, after some further experimentation with auth and trying things with the client, I did figure out the solution here. The error was that the URL wasn't found and the answer to the problem was that my URL wasn't structured correctly. It looks like the Forms API differs from the Drive/Sheets API in terms of how its API URL is formatted. Where the Drive API has a base URL of One note: I was not able to get this to work interactively using the
I think my initial problem is solved since I can get things to work in my Shiny app but perhaps it is worth exploring an integration of the Forms API into I appreciate your help here! It definitely led me in the right direction to keep testing things. I had tried quite a bit and got stuck but I should be ok for now. Edit: I realize I can also hook up the client to work interactively outside of Shiny with |
In googledrive and googlesheets4 this is a piece of info I feel like I learn from the relevant API's Discovery Doc and then somehow bake in at a rather low level. But it's been a long while since I touched any of that.
Yeah, that is definitely true. We've had no reason to enable Forms on it. I don't foresee making any changes to googledrive or the associated GCP project related to Forms. Glad you are sorted out! |
I admit this issue may be due to my incompetence at using
gargle
or a handful of other things but it might also be an issue with howgargle
interacts with the Forms API. I also have a StackOverflow issue open but it has not gotten much traffic.I have been working with
googledrive
andgooglesheets4
to make a Shiny app which serves as a project setup service for Google files. I have everything working locally. However, one of the files is a Google Form and I'd love to use the Forms API to help automate things further. I have been trying to follow along with the request helper functions guide. I, with some slight modifications to the files, successfully downloaded the Discovery Document for the Forms API and set up a call to the API but the call fails each time.However, it always tells me I need a json and not html. I've tried to do some digging to see what's going on but I'm stuck.
I think the parameters are correct. Google says the call only needs
formId
. Isgargle
not set up for the Forms API? Am I just missing something crucial? I appreciate any help and/or direction to post somewhere else if needed :).The text was updated successfully, but these errors were encountered: