Can I respond to a Survey Monkey survey by API? - surveymonkey

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.

Related

How can I post multiple survey responses using survey monkey API

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.

Creating sections in swagger

I'm writing a swagger spec and I have three separate endpoints. How do I separate them in my documentation? I want to have a clear distinction between example: Users, Posts & Other. So each one would have a CRUD description and displayed in swagger UI it would look like:
USERS
// user specs
POST
// post specs
OTHER
// other specs
You need to use tags to accomplish this.
So, on your "paths" object, you sort all your routes and on each one, you add a "tags": ["{resource}"] where it should be grouped.
For example:
"paths": {
"/users": {
"get": {
"tags": ["User"],
"description": "...",
},
"post": {
"tags": ["User"],
"description": "...",
}
},
"/posts": {
"get": {
"tags": ["Post"],
"description": "...",
},
"post": {
"tags": ["Post"],
"description": "...",
}
},
"/other": {
"get": {
"tags": ["Other"],
"description": "...",
},
"post": {
"tags": ["Other"],
"description": "...",
}
},
}
This is not obvious at all on the documentation. Actually the documentation is very complete but lacks an index and some organisation.

Creating a thread in Microsoft Graph

I'm using Fiddler to create a new thread to my conversation and I'm following the documentation here and I'm getting this error:
message="Posts" property missing in create conversation request body.
What's really weird is that I'm using the exact request model from the documentation.
POST https://graph.microsoft.com/v1.0/groups/<id>/conversations/<id>/threads
Content-type: application/json
Content-length: 419
{
"toRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
],
"topic": "topic-value",
"hasAttachments": true,
"lastDeliveredDateTime": "datetime-value",
"uniqueSenders": [
"uniqueSenders-value"
],
"ccRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
]
}
I understand that clearly the Posts property is missing, but where should this property placed?
Like this,
"topic": "topic-value",
"Posts": "This is a post" <<<
"hasAttachments": true,
didn't worked and threw the following error message:
"message": "Property Posts in payload has a value that does not match schema."
I'd really appreciate your input with this issue.
Many thanks in advance!
EDIT:
Added the following to the sample model and I was able to create a new thread:
"posts": [{}]
Basically I used the same model, but added a posts property and I managed to create a new thread:
{
"toRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
],
"topic": "topic-value",
"hasAttachments": true,
"lastDeliveredDateTime": "datetime-value",
"uniqueSenders": [
"uniqueSenders-value"
],
"posts": [{}], <<<< HERE, empty post
"ccRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
]
}
And I assume the composition of posts is:
"posts": [{
"body": {
"contentType": "html",
"content": "this is body content"
},
Hope it can help someone else in the future.

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