使用Surveymonkey API向调查发布电子邮件 [英] post an email to a survey using the surveymonkey api

查看:118
本文介绍了使用Surveymonkey API向调查发布电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Surveymonkey中进行了调查,并使用C#尝试通过Surveymonkey API将电子邮件地址添加到调查中.该API可以在GETS上正常工作,但我们尚未获得POST即可正常工作.我们回来的就是

we have a survey in surveymonkey and using c# to try and add the email addresses to the survey using the surveymonkey api. the api works fine for GETS but we have yet to get a POST to work. all we get back is

"docs":" https://developer.surveymonkey.com/api/v3/#错误代码","message":检索请求的资源时出错.","id":"1020","name":找不到资源","http_status_code":404

"docs": "https://developer.surveymonkey.com/api/v3/#error-codes", "message": "There was an error retrieving the requested resource.", "id": "1020", "name": "Resource Not Found", "http_status_code": 404

所有ID都是正确的,因为我们可以获取有关调查的信息,但不能过帐.我们已经授予了所有范围,因此在这方面不应有任何限制或限制.SurveyMonkey api支持也可能不存在,因为它们完全浪费时间,无法回答有关其api的单个问题.

all of the id's are correct as we can GET information about the survey but cannot POST to it. we have granted all the scopes so there shouldn't be a limitation or restriction on that side. SurveyMonkey api support might as well not exist as they are a complete waste of time and cannot answer a single question about their api.

以下代码是我们最近一次尝试通过POST调用api的尝试.我们将实际ID放在uri中,而不是{id}出于明显的原因,我没有在此处包括我们的ID.

the code below is our latest attempt at calling out to the api with a POST. we put the actual ids in the uri instead of {id} I did not include our id's here for the obvious reasons.

使用(var client = new HttpClient()){var uri = new Uri(" https://api.surveymonkey.net/v3/surveys/ {id}/collectors/{id}/messages/{id}/recipients-d);client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",ConfigurationManager.AppSettings ["SurveyMonkeyAccessToken"]);;client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));var content = new StringContent("{\" email \:+" + emailAddress +}",Encoding.UTF8,"application/json");var response = client.PostAsync(uri,content);ParseSurveyPostResponses(响应)}

using (var client = new HttpClient()) { var uri = new Uri("https://api.surveymonkey.net/v3/surveys/{id}/collectors/{id}/messages/{id}/recipients-d"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",ConfigurationManager.AppSettings["SurveyMonkeyAccessToken"]); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var content = new StringContent("{ \"email\": + " + emailAddress + " }", Encoding.UTF8, "application/json"); var response = client.PostAsync(uri,content); ParseSurveyPostResponses(response) }

任何人都可以使用其V3 API成功发布到Surveymonkey调查中吗?

anyone successfully post to a surveymonkey survey using their V3 api?

推荐答案

您到底想做什么?您是否要创建电子邮件收集器?您是否要在该电子邮件收集器上创建新消息?您是否要在该电子邮件中添加收件人?您是否要发送电子邮件?

What exactly are you trying to do? Are you trying to create an email collector? Are you trying to create a new message on that email collector? Are you trying to add recipients to that email? are you trying to send out the email?

创建电子邮件收集器:

POST /v3/<survey_id>/collectors
{
    "type": "email"
}

向电子邮件收集者添加消息:

POST /v3/collectors/<collector_id>/messages
{
    "type": "invite"
}

在邮件中

添加收件人:

POST /collectors/<collector_id>/messages/<message_id>/recipients
{
    "email": "test@example.com",
    "first_name": "Test",
    "last_name": "Example",
    "custom_fields": {
        "1": "First Value",
        "2": "Second Value",
        "3": "Third Value"
    },
    "extra_fields": {
        "field_name1": "field_value1",
        "field_name2": "field_value2"
    }
}

注意:您还可以在以下位置添加收件人批量

注意2:自定义字段存储在联系人列表中的关联联系人上,其他字段仅存储在该邮件的收件人上,并且只能通过API进行访问.

NOTE2: Custom fields are stored on the associated contact in your contact list, Extra Fields are only stored on the recipient for that message and only accessible through the API.

发送:/p>

POST /v3/collectors/<collector_id>/messages/<message_id>/send
{
    "scheduled_date": "2017-07-18T16:52:22"
}

注意:您可以排除 scheduled_date ,而只需发送 {} 即可立即发送邮件.

NOTE: you can exclude the scheduled_date and just send in {} to send the message right away.

这篇关于使用Surveymonkey API向调查发布电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆