How can I post multiple survey responses using survey monkey API - surveymonkey

I have posted a survey response to survey monkey like this and the response saved in survey monkey.
POST https://api.surveymonkey.com/v3/collectors/{collector_id}/responses
json = {
"custom_variables": {
"custvar_1": "one",
"custvar_2": "two"
},
"response_status": "completed",
"custom_value": "custom identifier for the response",
"date_created": "2015-10-06T12:56:55+00:00",
"ip_address": "127.0.0.1",
"recipient_id": "564728340",
{
"pages": [{
"id": "12345678",
"questions": [
{
"answers": [{
"choice_id": "12345678"
}],
"id": "12345678"
},
{
"answers": [{
"row_id": "12345678",
"col_id": "12345678",
"choice_id": "12345678"
}],
"id": "12345678"
}]
}]
}
I want to post multiple responses in a signle API call. Is is possible?

There isn't currently a way to bulk import responses with the SurveyMonkey API.
This is something that will likely be available in the future but there isn't a current ETA.

Related

How to post special characters to Amazon SQS using WSO2

we are trying to post json data to Amazon SQS which has special characters. But we are receiving exception while inserting data stating json is malformed. Following is the payload we have tested. [{ "ns2:Operation": { "core": { "system": "Local", "parameters": [{ "name": "name", "value": "qwerty" }, { "name": "operation", "value": "test" }, ], "actionDate": "11/12/2018", }, "ns2:action": "TESTING", "#xmlns:ns2": "http://test-app/testwebservice", "#xmlns": "http://test-app/testwebservice", } }]

Create a message with itemAttachment

Trying to send an email through Microsoft Graph where another email from user mailbox is to be used as an attachment.
What I am doing is something similar to:
POST https://graph.microsoft.com/v1.0/me/sendMail HTTP/1.1
authorization: bearer {access_token}
content-type: application/json
content-length: 96
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [{
"emailAddress": {
"address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}],
"attachments": [
"#odata.type": "#Microsoft.OutlookServices.ItemAttachment",
"name": "menu.txt",
"item": {
"id": "some_id"
<!--This is the id of an existing email in User's inbox -->
}
]
},
"saveToSentItems": "false"
}
This returns with
Cannot process input of abstract type Microsoft.OutlookServices.Item
Can anyone help with suggestions?

Can I respond to a Survey Monkey survey by API?

I have a page with another layout to my survey monkey survey.
Can I send this responses by API?
Yes you can, see the API docs at:
https://developer.surveymonkey.com/api/v3/#survey-responses
Example:
POST /v3/collectors/<collector_id>/responses
{
"custom_variables": {
"custvar_1": "one",
"custvar_2": "two"
},
"pages": [{
"id": "12345678",
"questions": [
{
"answers": [{
"choice_id": "12345678"
}],
"id": "12345678"
}]
}]
}
See the documentation for more details on how to use the API.

Can a json response can be partially paginate?

I'm wondering if a json can be partially paginate.
For example
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever."
}
}],
"included": [
{
"type": "people",
"id": 42,
"attributes": {
"name": "John"
}
},
{
...annnd 80000 others
}
}
]
}
Where included have soo many elements (80.000 for examples) than maybe we need pagination?
But if it's paginate and we go on the next page only included elements will change, the json will still return the data.articles.
Is it a correct behavior ?
First proposal :
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever."
},
"relationships": {
"users": {
"link": "https://website.com/api/v1/articles/1/users.json"
}
}
}]
}
To be compliant with the JSON API spec, your compound document must obey the full linkage requirement. Any included resources MUST be identified via relationship data.
In your example, you could fulfill this by adding a data member under the users relationship. You could then link to every included person.
If the relationship data is a partial set, you can use pagination links within the relationship object.

Rails: Fetch JSON Data from Remote URL / API Call

i am trying to fetch a json data in my rails app from a url. how to make this api call.
{
"name": "MagicList",
"count": 20,
"frequency": "realtime",
"version": 5,
"newdata": true,
"lastrunstatus": "success",
"lastsuccess": "Sat Apr 26 2014 14:34:40 GMT+0000 (UTC)",
"results": {
"collection1": [
{
"Title": {
"href": "http://www.magicbricks.com/propertyDetails/2-BHK-746-Sq-ft-Multistorey-Apartment-FOR-Sale-Sector-79-in-Gurgaon&id=C0gt4k2Fa9tzpSvf+uAgZw==",
"text": "2 BHK Multistorey Apartment in Sector-79"
},
"Price": "37.99 Lac(s)",
"Rate": "5,092",
"Size": "746 Sq-ft",
"Project Name": "",
"New_Resale": "New Property"
},
{
"Title": {
"href": "http://www.magicbricks.com/propertyDetails/2-BHK-1050-Sq-ft-Multistorey-Apartment-FOR-Sale-Sector-68-in-Gurgaon&id=M5jckQCuJaBzpSvf+uAgZw==",
"text": "2 BHK Multistorey Apartment in Sector-68"
},
"Price": "57.50 Lac(s)",
"Rate": "5,476",
"Size": "1050 Sq-ft",
"Project Name": "Project: Pareena Sec68",
"New_Resale": "New Property"
},
{
"Title": {
"href": "http://www.magicbricks.com/propertyDetails/3-BHK-1875-Sq-ft-Multistorey-Apartment-FOR-Sale-Sector-37C-in-Gurgaon&id=gw8zjmcA/b1zpSvf+uAgZw==",
"text": "3 BHK Multistorey Apartment in Sector-37C"
},
"Price": "60.0 Lac(s)\nOnwards",
"Rate": "3,200",
"Size": "1875 Sq-ft",
"Project Name": "Project: Spire Greens",
"New_Resale": "Resale"
}
}
}
dont know how it can be achieved, which gem should be used.
Using 'open-uri'
url = "http://..."
data = JSON.parse(open(url).read)
Or using 'net'
require "net/http"
url = "http://..."
resp = Net::HTTP.get_response(URI.parse(url))
data = JSON.parse(resp.body)
This is not an answer to your question, but stack overflow won't let me post a comment without 50 reputation.
You may want to edit your API key out of your question, since it's the equivalent of your password for using their API services.
Yes you can easily use builtin stuff:
uri = "https://yourapithinkg.com/list?api_key=#{ENV.fetch('API_KEY')}"
result = JSON.parse(Net::HTTP.get(URI.parse(uri)))
Most people like to load in other libraries but its not really worth it.

Resources