Skip to content

Cannot filter GetSubmissions by formIDs #2

@lilith72

Description

@lilith72

GetSubmissions cannot filter by formIDs due to a formatting bug.

When CreateConditions formats the filter, it always puts quotes around the values. The correct format is:
{"formIDs":["your-form-id","your-form-id#2"]}
ref: https://api.jotform.com/docs/#user-submissions
to filter by multiple form IDs. The c# API adds extra quotes resulting in:
{"formIDs":"["your-form-id","your-form-id#2"]"}

Can be fixed with:
`private NameValueCollection CreateConditions(int offset, int limit, Dictionary<String, String> filter, String orderBy)
{
NameValueCollection parameters = new NameValueCollection();

        if (offset != 0)
            parameters.Add("offset", offset.ToString());

        if (limit != 0)
            parameters.Add("limit", limit.ToString());

        if (filter != null)
        {
            String value = "{";
            int count = 0;

            foreach (KeyValuePair<String, String> pair in filter)
            {
                **if (pair.Key == "formIDs")
                {
                    value = value + "\"" + pair.Key + "\":" + pair.Value;
                }
                else
                {
                    value = value + "\"" + pair.Key + "\":\"" + pair.Value + "\"";
                }**

                count++;

                if (count < filter.Count)
                    value = value + ",";
            }

            value = value + "}";

            Console.WriteLine(value);
            parameters.Add("filter", value);
        }

        if (orderBy != null)
            parameters.Add("orderby", orderBy);

        return parameters;
    }`

Not sure if there are other filters that can have multiple values, but they probably suffer the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions