Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

GetResponses() matchSingleAnswer.Success bombs with "[comment(9)]" value #1

Open
JoshRefactored opened this issue Jul 27, 2016 · 3 comments

Comments

@JoshRefactored
Copy link

Hi Guys,

Love the API, thank you!

I'm implementing it and doing some testing against our SG account. When using GetResponses(), its bombing when the matchSingleAnswer.Success check is encountered with a value of "[comment(9)]". I took a screenshot but I don't see an option to upload it so hopefully this is enough detail to help you trouble shoot.

Thanks.

@bernardwolff
Copy link

bernardwolff commented Jul 27, 2016

Thanks for reporting this. Without seeing the JSON data that it's trying to parse, it's hard to troubleshoot this. Could you please post the JSON data that is returned from the API? I suggest removing any sensitive data first before posting it. Here's how you can get the data: put a breakpoint at line 278 of ApiClient.cs. Then when it hits that breakpoint, copy the value of the fullUrl variable, and then paste it into your browser. You can then copy/paste the contents of the page.

@JoshRefactored
Copy link
Author

I removed the other 'data' objects for brevity but left the first one where the last key/pair value is causing the issue e.g. comment(9).

{
"result_ok": true,
"total_count": "776",
"page": "1",
"total_pages": 16,
"results_per_page": 50,
"data": [{
"id": "1",
"contact_id": "",
"status": "Deleted",
"is_test_data": "1",
"datesubmitted": "2016-07-06 09:59:13",
"SessionID": "1122334455",
"Language": "English",
"datestarted": "2016-07-05 11:52:55",
"iLinkID": "123456",
"sResponseComment": "",
"responseID": "1",
"[question(3), option(0)]": "Jul 05, 2016 12:00:43 Success: Email Sent to: [email protected]",
"[question(5)]": "Yes",
"[question(6)]": "Another yada",
"[question(7), option(10006)]": "bla.site",
"[question(7), option(10007)]": "yada advocacy group site",
"[question(7), option(10008)]": "",
"[question(7), option(10009)]": "",
"[question(7), option(10010)]": "yadayada.com or yada scrub Facebook posts",
"[question(7), option(10011)]": "",
"[question(7), option(10012)]": "",
"[question(7), option(10028)]": "",
"[question(7), option(10031)]": "",
"[question(7), option("10034-other")]": "",
"[question(7), option(10034)]": "",
"[question(8)]": "Yes",
"[question(9)]": "Yes",
"[question(10)]": "Some",
"[question(11)]": "test",
"[question(12)]": "test",
"[question(13)]": "[email protected]",
"[question(20)]": "yada",
"[question(20), option("10040-other")]": "",
"[question(21), option(10041)]": "",
"[question(21), option(10042)]": "disease",
"[question(21), option(10043)]": "",
"[question(21), option(10044)]": "",
"[question(21), option(10045)]": "",
"[question(21), option(10046)]": "",
"[question(21), option(10047)]": "",
"[question(21), option(10048)]": "",
"[question(21), option(10049)]": "",
"[question(21), option(10050)]": "",
"[question(21), option(10051)]": "",
"[question(21), option(10052)]": "",
"[question(21), option(10053)]": "Other",
"[question(21), option("10091-other")]": "",
"[question(21), option(10091)]": "",
"[question(22)]": "7 months- 2 years",
"[question(23)]": "Female",
"[question(24)]": "21-30",
"[question(25)]": "United States of America",
"[question(25), option("10080-other")]": "",
"[question(25), option("10084-other")]": "",
"[question(25), option("10085-other")]": "",
"[question(25), option("10086-other")]": "",
"[question(26)]": "2 trials",
"[question(27), option(10094)]": "",
"[question(27), option(10095)]": "",
"[question(27), option(10096)]": "",
"[question(27), option("10098-other")]": "",
"[question(27), option(10098)]": "",
"[question(34), option(10099)]": "",
"[question(34), option(10100)]": "",
"[question(34), option(10101)]": "",
"[question(34), option(10102)]": "",
"[question(34), option("10103-other")]": "",
"[question(34), option(10103)]": "",
"[question(35)]": "",
"[url("id")]": "123456",
"[url("link_id")]": "",
"[url("controller")]": "builder",
"[url("action")]": "test-link-proxy",
"[url("module")]": "default",
"[variable("STANDARD_IP")]": "95.181.24.1234",
"[variable("STANDARD_LONG")]": "-80.735011100610352",
"[variable("STANDARD_LAT")]": "35.293598111175049",
"[variable("STANDARD_GEOCOUNTRY")]": "United States",
"[variable("STANDARD_GEOCITY")]": "Charlotte",
"[variable("STANDARD_GEOREGION")]": "NC",
"[variable("STANDARD_GEOPOSTAL")]": "21213",
"[variable("STANDARD_RESPONSETIME")]": "468",
"[variable("STANDARD_COMMENTS")]": "",
"[variable("STANDARD_DEVICE")]": "Desktop",
"[variable("STANDARD_DATAQUALITYCOUNTER")]": "",
"[variable("STANDARD_CHECKBOXONE_COUNT")]": "",
"[variable("STANDARD_CHECKBOXONE")]": "",
"[variable("STANDARD_STRAIGHTLINING_COUNT")]": "",
"[variable("STANDARD_STRAIGHTLINING")]": "",
"[variable("STANDARD_OPENTEXTGIBBERISH_COUNT")]": "",
"[variable("STANDARD_OPENTEXTGIBBERISH")]": "",
"[variable("STANDARD_OPENTEXTBADWORDS_COUNT")]": "2",
"[variable("STANDARD_OPENTEXTBADWORDS")]": "11,12",
"[variable("STANDARD_OPENTEXTONEWORDREQUIREDESSAY_COUNT")]": "2",
"[variable("STANDARD_OPENTEXTONEWORDREQUIREDESSAY")]": "11,12",
"[variable("STANDARD_CHECKBOXALL_COUNT")]": "",
"[variable("STANDARD_CHECKBOXALL")]": "",
"[variable("STANDARD_AVGQUESTSECONDS")]": "27.882",
"[variable("STANDARD_FINGERPRINT")]": "",
"[variable("STANDARD_GEODMA")]": "517",
"[variable("STANDARD_REFERER")]": "https://app.surveygizmo.com/builder/test-link-proxy?id=123456&__sgtarget=1&__sg_collab_test=1&__sg_build_test=1&link_id=&__sg_tester=c3VydmV5Z2l6bW9AcGF0aWVudHBvd2VyLmluZm8%3D&__sg_tester_name=1234%3D%3D&__sg_tester_id=3456",
"[variable("STANDARD_USERAGENT")]": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
"[variable("PORTAL_RELATIONSHIP")]": "",
"[variable("1-shown")]": "1",
"[variable("3-shown")]": "1",
"[variable("4-shown")]": "1",
"[variable(5)]": "10001",
"[variable("5-shown")]": "1",
"[variable(6)]": "10004",
"[variable("6-shown")]": "1",
"[variable("7-shown")]": "1",
"[variable(8)]": "10013",
"[variable("8-shown")]": "1",
"[variable(9)]": "10015",
"[variable("9-shown")]": "1",
"[variable(10)]": "10018",
"[variable("10-shown")]": "1",
"[variable("11-shown")]": "1",
"[variable("12-shown")]": "1",
"[variable("13-shown")]": "1",
"[variable("17-shown")]": "1",
"[variable(20)]": "10037",
"[variable("20-shown")]": "1",
"[variable("21-shown")]": "1",
"[variable(22)]": "10055",
"[variable("22-shown")]": "1",
"[variable(23)]": "10060",
"[variable("23-shown")]": "1",
"[variable(24)]": "10061",
"[variable("24-shown")]": "1",
"[variable(25)]": "10069",
"[variable("25-shown")]": "1",
"[variable(26)]": "10087",
"[variable("26-shown")]": "1",
"[variable("27-shown")]": "",
"[variable("30-shown")]": "",
"[variable("34-shown")]": "",
"[variable(35)]": "",
"[variable("35-shown")]": "",
"[comment(9)]": ""
}
]
}

@bernardwolff
Copy link

I was away on vacation and did not get a chance to look at this until now. I think the problem stems from using hard-coded magic numbers in Model.cs. Try changing line 344 to this:
// add 2 because of [ and ( characters
var groupStringLen = (matchSingleAnswer.Groups.Count > 0) ? matchSingleAnswer.Groups[1].Length + 2 : 10;
var num = name.Substring(groupStringLen, name.IndexOf(')') - groupStringLen);
var index = int.Parse(num);

This will use the length of the matched word (question, calc, comment), rather than a hardcoded value of 10. A similar approach can be used for the other matches. When I get time to test this change I'll push it if it works. Feel free to try making the change yourself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants