Please save me stack overflow .. and I’m PRAYING someone has registered a participant using the API (and submitting an answer to a custom question).
Ok, so first off, here’s the documentation for create registrant:
POST https://api.citrixonline.com/G2W/rest/organizers/73563532324/webinars/89... HTTP/1.1
Accept: application/json
Accept: application/vnd.citrix.g2wapi-v1.1+json
Content-Type: application/json
Authorization: OAuth oauth_token={oauthToken}
{
"firstName":"Saumil",
"lastName":"Jhaveri",
"email":"test@test.com",
"address":"650+Townsend+St,+St.+325",
"city":"San+Francisco",
"state":"California",
"zipCode":"94103",
"country":"United+States",
"phone":"3123751884",
"industry":"Accounting",
"organization":"Citrix",
"jobTitle":"Software+Engineer",
"purchasingTimeFrame":"13+months",
"roleInPurchaseProcess":"Decision+Maker",
"numberOfEmployees":"120",
"questionsAndComments":"No+Comments!",
"responses":[
{
"questionKey":152,
"responseText":"Fantastic!"
}, {
"questionKey":151,
"answerKey":152
}
]
}
So, as you can see from the json rest example above, the REST body needs to be an array for the “normal” values such as name, email, etc…
If you look near the bottom of the example, you’ll see an array inside this array, called responses..
This array contains arrays of the custom question IDs and the user responses.
So what happens when there’s only one custom question?
I have tried:
array('firstName' => $fname, 'lastName' => $lname, 'email' => $em,
'responses' => array('questionKey' => 300000000000042400, 'responseText' => $custom));
and also tried (an array of arrays even though there’s only one question):
array('firstName' => $fname, 'lastName' => $lname, 'email' => $em,
'responses' => array(array('questionKey' => 300000000000042400, 'responseText' => $custom)));
If I run a json_encode on my data, This is the output
{
"firstName":"Ellis",
"lastName":"Ryan",
"email":"ryanthecloser@gmail.com",
"responses":[
{
"questionKey":3.0e+17,
"responseText":"http:\/\/facebook.com\/doubleyourlikes"
}
]
}
While I was typing this question, I think I see the issue … my json data (more specifically questionkey) is being converted to scientific notation … I tried submitting questionKey as a string, but that did not work..
I’m hoping the scientific notation is the problem. Anyone have any ideas how to make a number in php this big:
300000000000042400
And be able to encode_json without having the number converted? Or, if anyone has successfully gotten custom question responses to appear for a registrant using the api, please let me know!
Thanks in advance!
sigh
Passing the questionKey as a string is 100% fine, so that problem is gone…
My issue was actually that there’s TWO versions of create registrant:
Version one: accepts name and email and discards EVERYTHING else
Version two: add
Accept: application/vnd.citrix.g2wapi-v1.1+json
to the headers to select the second version. The second version allows custom fields.
Because I didn’t include the extra header param, my custom field data was discarded!
Grrrr I read that tons of times in the documentation … RTM!, and DO what it says lol!