2

当我使用 RestSharp 在 Mailchimp 上发布活动时,它告诉我我的 API 密钥丢失,但是当我单击“获取活动”时,它成功地向我显示了所有活动数据。

谁能告诉我哪里出错了?这是我的代码:

public MailChimpPostModel PostCampaign(MailChimpPostModel post)
{
    var auth = _userBusinessObject.GetUserWebsiteAuthorizationByWebsite(_userId, 
                                                                   _websiteId,
                                                                   _linkvanaNetworkSiteId);
    ApiBaseUrl = <url> ;
    if (auth == null)
        throw new RestRequestResponseException { Error = RestErrorsEnum.NotAuthenticated };

    var request = new RestRequest(3.0/campaigns, Method.POST);
    request.AddParameter("access_token", <Token>);
    request.AddParameter("apikey", <Token> + "-" + <dc>);
    request.AddHeader("content-type", "application/json");
    request.AddBody(post);
    var response = Execute<MailChimpPostModel>(request);
    return response;
}
4

1 回答 1

2
// replace usX to match the last 3 of your API
var client = new RestClient("https://usX.api.mailchimp.com/3.0/");
client.Authenticator = new HttpBasicAuthenticator("user", APIKey);
于 2016-04-23T20:16:35.077 回答