Cannot retrieve SurveyGizmo data in RStudio via API

Code:
api_key = "XXXXXX";
gizmo_response = pullsg(XXXXX, api_key, completes_only=TRUE, clean=TRUE)

But I get the following error,
Error in pullsg(XXXXXXX, api_key, completes_only = TRUE, clean = TRUE) :
could not find function "pullsg"

Have downloaded these packages (knitr, devtools, dplyr, httr, shiny, tidyr, ggplot2, stringr, zoo, forcats,tidyverse and Rsurveygizmo)

Have also tried;
api_key <- "XXXXXX";
gizmo_response <- pullsg(XXXXX, api_key, completes_only=TRUE, clean=TRUE) but on execution same error 'function pullsg not found'.

Need suggestions! Thank you!

In addition to installing packages, you need to load or attach them each time you use them in a new session using a library() call. In this case, it looks like pullsg() is a function inside Rsurveygizmo, so you'd need library(Rsurveygizmo).

You might take a look at the brief Basics section in ModernDive, which gives some examples of error messages you might get when you first start out:
https://moderndive.com/2-getting-started.html#code

Also, R is case-sensitive. So, Rsurveygizmo is not the same as rsurveygizmo. I think you might be right in this case, but it's something to look out for (I'm not sure why, but the GitHub repo for that package seems not to match the declared package name).

1 Like

I talked to SurveyGizmo tech support about something related to this a while ago.

It's my understanding that rsurveygizmo, developed by DerekYves, was written based on an old version of the SurveyGizmo API. SurveyGizmo doesn't support the R package directly but it can be updated in GitHub. I would encourage anybody to update it to the most recent version of the SurveyGizmo API!

Thank you so much for the input and I did think the same and tried it earlier and the error then was ERROR 401.

@kendalwolf I did think about this possibility and have contacted SurveyGizmo for the same but have not heard back from them yet. Could you please share further details of how you solved your issue.
Thank you so so much !

Yeah a 401 Error means you're unauthorized, so either your credentials aren't valid, or, as @kendalwolf suggests, this could be working off of an old API — meaning your credentials aren't working because they're for the wrong API.
https://httpstatuses.com/401

I solved the issue by exporting my SurveyGizmo survey results to a CSV. Then I imported them into R using something like data = read.csv("surveygizmo.csv", header = TRUE)

Again, I would urge you to update Rsurveygizmo on GitHub so that it uses SurveyGizmo's latest API, which is v5.
https://apihelp.surveygizmo.com/help/versions-methods

The last commit to Rsurveygizmo was in August 2016 -- it probably used v3 of the SurveyGizmo API.

1 Like

@mara Thanks you so much for the information, we were working off an old API but it was the same scenario even with the new API code.

1 Like

@kendalwolf Well we are using latest SurveyGizmo API hence I can't really figure out where the error lies. For now we are exporting through CSV but it would have been great if this code worked as it was working well until a few weeks ago.
Thank you so much for your input and time!

@internp The rsurveygizmo package needs to be modified on GitHub. It makes calls to SurveyGizmo's API using commands that apply to an old version of the API. If you're good at coding R packages, I recommend that you update the rsurveygizmo package and upload the fix to GitHub.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.