C#Eventbrite创建事件

时间:2019-11-28 05:44:43

标签: c# api eventbrite

我试图与Eventbrite API集成,我只是尝试使用RestSharp创建一个事件。

// Request to create an event.
var restClient = new RestClient("https://www.eventbriteapi.com/v3/");

这是我正在使用{MyOrganiserID}和MyToken替换我的实际令牌的基本URL。

var createEventRequest = new RestRequest("organizations/{MyOrganiserID}/events", Method.POST);
createEventRequest.AddHeader("Authorization", "Bearer MyToken");
createEventRequest.AddHeader("content-type", "application/x-www-form-urlencoded");

createEventRequest.AddQueryParameter("event.name.html", "My Event is good mate");
createEventRequest.AddQueryParameter("event.start.utc", "2019-12-12T18:00:00Z");
createEventRequest.AddQueryParameter("event.start.timezone", "Australia/Melbourne");
createEventRequest.AddQueryParameter("event.end.utc", "2019-12-12T20:00:00Z");
createEventRequest.AddQueryParameter("event.end.timezone", "Australia/Melbourne");
createEventRequest.AddQueryParameter("event.currency", "AUD");

IRestResponse createEventRestResponse = restClient.Execute(createEventRequest);
var requestContent = createEventRestResponse.Content;

我还尝试使用RestSharp API中的AddBody和AddXMLBody在请求正文中发送参数。

createEventRequest.AddBody("event.name.html=<p>A DARQ Room Production Woof Woof</p>&event.start.utc=2019-12-12T18:00:00Z&event.start.timezone=Australia/Melbourne&event.end.utc=2019-12-12T20:00:00Z&event.end.timezone=Australia/Melbourne&event.currency=AUD");
createEventRequest.AddXmlBody("event.name.html=<p>A DARQ Room Production Woof Woof</p>&event.start.utc=2019-12-12T18:00:00Z&event.start.timezone=Australia/Melbourne&event.end.utc=2019-12-12T20:00:00Z&event.end.timezone=Australia/Melbourne&event.currency=AUD");

我也尝试过通过AddParameters方法添加字段。

createEventRequest.AddParameter("event.name.html", "This is a good event mate");
createEventRequest.AddParameter("event.start.utc", "2019-12-12T18:00:00Z");
createEventRequest.AddParameter("event.start.timezone", "Australia/Melbourne");
createEventRequest.AddParameter("event.end.utc", "2019-12-12T20:00:00Z");
createEventRequest.AddParameter("event.end.timezone", "Australia/Melbourne");
createEventRequest.AddParameter("event.currency", "AUD");

使用AddQueryParameter时,我得到了401未经授权,我也尝试将令牌作为查询参数,但仍然显示我未经授权。

我得到的另一个错误是

{
    "status_code": 403, 
    "error_description": "You do not have permission to access the resource you requested.", 
    "error": "NOT_AUTHORIZED"
}

当我通过请求正文发送参数时。

任何人都能提供的帮助将不胜感激。

0 个答案:

没有答案