C# library for Survey Solutions API

In 2018 I was working on implementing the C# client for the Survey Solutions API. Many things have changed since then, workspaces introduced, some queries extended. Notably the export procedure of the v1 of the API is no longer supported in contemporary versions of Survey Solutions (use v2 instead, as discussed here.) And of course there is a million ways of doing some of these things more efficiently. But hope this will be useful if you are thinking about where to get started.

:earth_americas: Link to source

(as-is, use at own risk, no warranties implied).

1 Like

Here is another implementation of a client library that can be used. Compiled and ready to be added as a nuget package

1 Like

Hi andrii,

I trying to use your library but i have a problem with some usersApi functions.

When i call funcion SupervisorsListAsync i got empty or 0 output

    Dim susoUsers As UserList = Await susoClient.Users.SupervisorsListAsync()

    Dim User = Await susoClient.Users.GetUserDetailsAsync("garant")

I also tried some other functions like this and they are working fine…

    Dim susoAssign = Await susoClient.Assignments.ListAsync(New AssignmentsListFilter())
    Dim susoQ = Await susoClient.Questionnaires.ListAsync

Thank you for help.

1 Like

Thank you for trying out the library. Will check and get back to you

made an update, please check new version, method should work properly now NuGet Gallery | SurveySolutionsClient 1.2.1

Hi andrii,

Thanks for quick response.

SupervisorsListAsync()

First function is partly fixed but still cant get user data like userID and username.

Výstřižek

GetUserDetailsAsync("username")

Second function is without changes, cant receive any data about user.

Again thank you for contribution. Here is a fixed version

SupervisorsListAsync() works great now.

but there is still problem in function
GetUserDetailsAsync("username")

image

Thanks.

1 Like

Here is a fix

1 Like

Hi andrii,

I trying to filter completed interviews, because /api/v1/interviews is deprecated your library probably will not suppert it.
So I trying to use GraphQl, if i understand how to use it properly i should use model InterviewApiItem where i can filter list by ID, Status, etc… But this model “InterviewApiItem” is missing in your library.

Thanks.

Here is an example of using graphql API. Its a bit experimental atm, might be changed in future releases:

var builder = new HeadquartersQueryQueryBuilder()
    .WithInterviews(
        new IPagedConnectionOfInterviewQueryBuilder()
            .WithNodes(new InterviewQueryBuilder().WithAllScalarFields())
            .WithFilteredCount()
            .WithTotalCount(),
        where: new InterviewsFilter
        {
            Status = new InterviewStatusOperationFilterInput
            {
                Eq = InterviewStatus.Completed
            }
        },
        workspace: "primary");

var result = await this.service.GraphQl.ExecuteAsync<GraphQlResponse>(builder);
1 Like

Hi,
I’m trying to get familiar with your .Net API package… in my code, everything else works, but i’m getting a 400 error when i debug the graphQl, can you please help me identify my problem. Thanks… Also, is there a way to see actual data from exports ( the r package returns a tabular dataframe that can be queried, is this possible with the .net package?)

var builder = new HeadquartersQueryQueryBuilder()
.WithInterviews(
new IPagedConnectionOfInterviewQueryBuilder()
.WithNodes(new InterviewQueryBuilder().WithAllScalarFields())
.WithFilteredCount()
.WithTotalCount(),
where: new InterviewsFilter
{
Status = new InterviewStatusOperationFilterInput
{
Eq = SurveySolutionsClient.GraphQl.InterviewStatus.Completed
}
},
workspace: “eid”);

        var result = await client.GraphQl.ExecuteAsync<GraphQlResponse>(builder);

Hello, maybe there were some changes survey solutions api, what version of Survey Solutions are you using?

Try this query:

            var builder = new HeadquartersQueryQueryBuilder()
                .WithInterviews(
                    new IPagedConnectionOfInterviewQueryBuilder()
                        .WithNodes(new InterviewQueryBuilder().WithAllScalarFields())
                        .WithFilteredCount()
                        .WithTotalCount(),
                    workspace: "primary",
                    where: new InterviewsFilter()
                    {
                        Status = new InterviewStatusOperationFilterInput
                        {
                            Eq = InterviewStatus.Completed
                        }
                    });

            var result = await this.service.GraphQl.ExecuteAsync<GraphQlResponse>(builder);