I've created a web application that using SurveyMonkey API and gathers the responses to a bunch of surveys I've created with SurveyMonkey. It's a BASIC account, however when I call the method get_responses on a survey it only works for one of my surveys.
I have 6 surveys that have been completed but it returns a json response with null values for 5 of my surveys.
"{"status": 0, "data": [null, null, null, null, null, null]}"
Does anyone know why this is the case?
You need to call get_respondent_list for each individual survey, and then pass a list of respondent ids to get_responses in the parameter 'respondent_ids'. You also need to ensure you pass the correct survey_id to get_responses. If you're getting null values, this means you are either passing invalid respondent ids, or respondent ids that do not correspond to the survey_id you are sending.
See here for more info: https://developer.surveymonkey.com/mashery/get_responses and https://developer.surveymonkey.com/mashery/get_respondent_list
Related
Querying the graph API returns null for many fields which should not be null, for example jobTitle, userType, createdDateTime, and isAccountEnabled. Why are these fields showing up as null? Is there something that needs to be enabled from the global Azure AD?
How can I get these fields to return with their proper values rather than null?
You need the permission "Directory.Read.All" at least.
So that you can read user data in your organization's directory. Otherwise, you will get "null" value.
Microsoft Graph permissions reference - Directory permissions
When I POST a Core Data managed object using RestKit, RestKit doesn't update the existing object but creates a new object instead.
The returned JSON always contains the newly created object, but wraps it into a plural keyed array. I found that if I change this to just the one object, the updating works as expected. However, I would like to keep the array in the response so that all responses are consistently in the plural form.
Is there any way I can make RestKit update the record, even when returned from the server wrapped in an array?
Possible solution: identificationAttribute?
On my entities I have an identificationAttribute called remoteID. This is the primary unique key of the record. This will be 0 before the POST, because the object is not yet on the server. I thought that by adding a second identificationAttribute called insertionID, setting that before the POST, and then returning it in the response, would allow RK to find the existing entity in the local store. Alas, it didn't work.
What did work however, was setting the remoteID before the POST, to the next auto increment value on the server! What could explain that it works with remoteID, but not with a second insertionID?
Example request
{
"user": {
"email": "example#example.com"
}
}
Response
{
"users": [{
"email": "example#example.com"
}]
}
I would like to keep the array in the response so that all responses are consistently in the plural form.
You shouldn't, because this is an individual request and response, not a composite.
Your idea about identificationAttribute is correct, but doesn't apply when the response is an array. The array is the trigger (or one of the possible triggers) to abandon the match with the source object and create new objects. Changing this would be hard.
Without knowing more about your real situation, 2 alternatives:
Change the JSON
POST a dictionary instead of the real object and then you won't have a duplicate
When you use multiple identification attributes, all must match for the destination object to be found.
Take care - don't create multiple mappings for the same entity with different identification attributes or you will most likely be debugging the lookup cache for a long time trying to work out what's happening...
If the identity matches before the request is made then the array isn't an issue. To explain the above in more detail:
When you POST an object, RestKit expects to get that object back. So, if you POST one object and get an array back it doesn't know what to do, because it can't map an array into an object. So, it tries to lookup based on the identification attribute (if they exist). If the POSTed object didn't have an id and the returned object does then it will never match. If you set it before POSTing then it will match.
I am using the Youtube Javascript client to request a list of the recommendations for the OAuth'd user:
gapi.client.youtube.activities.list({
"part": "snippet",
"home": true,
"maxResults": 50
}).execute(function(data) {
// etc
});
This returns a load of recommendations, as expected, and the recommendations don't appear to change. However, the ID of the recommendation (data.items[k].id) changes (usually towards the end of the ID) each time I make the request.
When I was making a similar call for Google+, the IDs that come back are the same every time for posts etc.
So should these IDs be immutable (i.e. this is a bug in the API) or is my assumption that they are always the same invalid? The documentation says:
The ID that YouTube uses to uniquely identify the activity.
... which doesn't really help one way or the other.
If this is the case, how do you uniquely identify these items?
Assuming you want the video id, you need to specify contentDetails as the part.
gapi.client.youtube.activities.list({
"part": "snippet,contentDetails",
"home": true,
"maxResults": 50
}).execute(function(data) {
// etc
});
I'm working on a project where we plan to send some data back to Desire2Learn. I've gotten pretty far, I can query the user list, I can get their profile id, get their profile, and then update said profile.
I noticed when looking through the documentation, that I if I call /d2l/api/lp/1.3/users/?OrgDefinedId=123456789 it returns just that one user as seen below.
[
{
"OrgId": "{{ORG_ID}}",
"UserId": 12345,
"FirstName": "Christopher",
"MiddleName": null,
"LastName": "Sterling",
"UserName": "csterli1",
"ExternalEmail": "{MY_EMAIL}",
"OrgDefinedId": "123456789",
"UniqueIdentifier": "{{UID}}",
"Activation": {
"IsActive": true
},
"DisplayName": "Chris Sterling"
}
]
The problem, I believe, that I've ran into is that in order for me to get the Profile ID, I can't call the url above, but instead, I have to call /d2l/api/lp/1.3/enrollments/orgUnits/{{ORG_ID}}/users/. That call there returns the Profile ID, but it also returns all users, in increments of 100.
What I am wondering is if there is a way that I can pass the ?OrgDefinedId to the enrollments method and have it return the user object?
If that isn't the case, I'm wondering, is there a better way to do what I am trying to do. It currently seems like I am going to be making a large number of calls to get all our users so we can get their profile id for a given user.
Thanks!
There is not currently a better filter on the enrollments calls, nor does the profile identifier appear in the administrative user data record returned from the .../users/ calls.
The GET classlist for orgunit call also returns data containing user profile identifiers, and it returns data in a JSON array rather than a paged set. The Enrollment.ClasstlistUser structure contains the LMS UserId (Identifier) and user profile ID (ProfileIdentifier) data and can also contain the OrgDefinedId property. In order to get back that last data, though, your LMS must be configured to provide org-defined IDs in the Classlist tool. If it's not, then to make the union between profile identifiers and org-defined identifiers, you'll need to use the LMS UserId as the common value, and make a series of calls to get back two data sets you can join together.
Consider the following domain models:
class Sales{
String salesInvoice
Customer customer
}
class Customer{
int customerNumber
String name
}
The problem: I am trying to retrieve all the sales given a customer. Thus the code:
def sales = Sales.findAllByCustomer(Customer.get(params.id))
I don't have problem with getting the customer. But when I use println sales.dump() I get something like
<java.util.ArrayList#d3a25f8 elementData=[mypackage.Sales : null, mypackage.Sales : null] size=2 modCount=3>
If I understand correctly, this means that the query was able to get a list of Sales but what I don't quite understand is why is it returning a list of nulls? I've tried eager fetching but I don't think that will work in this particular problem. So how to I get a list of non-null Sales objects?
The objects you have shown are not NULL, but the id of the objects is currently NULL: Each grails domain object has a toString() method which will print ${name of the class} : ${id of the instance}. If you receive outputs, like you have shown, it generally means, that your instances are existing (otherwise a NPE would have been thrown!), however the id is not yet fetched from the DB.
I guess you are creating the objects in the code before. You need to flush the context, otherwise id's are not created.
You should declare, that your Sale belongs to a Customer. http://grails.org/doc/latest/guide/GORM.html#manyToOneAndOneToOne
BTW: Name you domain classes in singular. So rename Sales to Sale.